Module WS::BaseTypes
In: vendor/actionwebservice/lib/action_web_service/vendor/ws/types.rb

Methods

Public Class methods

[Source]

    # File vendor/actionwebservice/lib/action_web_service/vendor/ws/types.rb, line 42
42:       def base_type?(klass)
43:         !(canonical_type_class(klass) rescue nil).nil?
44:       end

[Source]

    # File vendor/actionwebservice/lib/action_web_service/vendor/ws/types.rb, line 50
50:       def canonical_param_type_class(spec)
51:         klass = spec.is_a?(Hash) ? spec.values[0] : spec
52:         array_element_class = klass.is_a?(Array) ? klass[0] : nil
53:         klass = array_element_class ? array_element_class : klass
54:         klass = type_name_to_class(klass) if klass.is_a?(Symbol) || klass.is_a?(String)
55:         base_class = canonical_type_class(klass) rescue nil
56:         klass = base_class unless base_class.nil?
57:         array_element_class ? [klass] : klass
58:       end

[Source]

    # File vendor/actionwebservice/lib/action_web_service/vendor/ws/types.rb, line 60
60:       def canonical_param_type_spec(spec)
61:         klass = canonical_param_type_class(spec)
62:         spec.is_a?(Hash) ? {spec.keys[0]=>klass} : klass
63:       end

[Source]

    # File vendor/actionwebservice/lib/action_web_service/vendor/ws/types.rb, line 46
46:       def canonical_type_class(klass)
47:         type_name_to_class(class_to_type_name(klass))
48:       end

[Source]

    # File vendor/actionwebservice/lib/action_web_service/vendor/ws/types.rb, line 65
65:       def canonical_type_name(name)
66:         name = name.to_sym
67:         case name
68:           when :int, :integer, :fixnum, :bignum
69:             :int
70:           when :string, :base64
71:             :string
72:           when :bool, :boolean
73:             :bool
74:           when :float, :double
75:             :float
76:           when :time, :datetime, :timestamp
77:             :time
78:           when :date
79:             :date
80:           else
81:             raise(TypeError, "#{name} is not a valid base type")
82:         end
83:       end

[Source]

    # File vendor/actionwebservice/lib/action_web_service/vendor/ws/types.rb, line 24
24:       def class_to_type_name(klass)
25:         if WS.derived_from?(Integer, klass) || WS.derived_from?(Fixnum, klass) || WS.derived_from?(Bignum, klass)
26:           :int
27:         elsif klass == String
28:           :string
29:         elsif klass == TrueClass || klass == FalseClass
30:           :bool
31:         elsif WS.derived_from?(Float, klass) || WS.derived_from?(Precision, klass) || WS.derived_from?(Numeric, klass)
32:           :float
33:         elsif klass == Time || klass == DateTime
34:           :time
35:         elsif klass == Date
36:           :date
37:         else
38:           raise(TypeError, "#{klass} is not a valid base type")
39:         end
40:       end

[Source]

    # File vendor/actionwebservice/lib/action_web_service/vendor/ws/types.rb, line 7
 7:       def type_name_to_class(name)
 8:         case canonical_type_name(name)
 9:         when :int
10:           Integer
11:         when :string
12:           String
13:         when :bool
14:           TrueClass
15:         when :float
16:           Float
17:         when :time
18:           Time
19:         when :date
20:           Date
21:         end
22:       end

[Validate]