ohm-contrib 0.0.34 → 0.0.35
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ohm/contrib.rb +1 -1
- data/lib/ohm/contrib/typecast.rb +28 -0
- data/test/typecast_array_test.rb +5 -0
- data/test/typecast_date_test.rb +5 -0
- data/test/typecast_decimal_test.rb +5 -0
- data/test/typecast_float_test.rb +5 -0
- data/test/typecast_hash_test.rb +5 -0
- data/test/typecast_integer_test.rb +5 -0
- data/test/typecast_string_test.rb +4 -0
- data/test/typecast_time_test.rb +5 -0
- metadata +2 -2
data/lib/ohm/contrib.rb
CHANGED
data/lib/ohm/contrib/typecast.rb
CHANGED
@@ -82,6 +82,10 @@ module Ohm
|
|
82
82
|
|
83
83
|
class String < Primitive
|
84
84
|
delegate_to ::String
|
85
|
+
|
86
|
+
def type
|
87
|
+
::String
|
88
|
+
end
|
85
89
|
end
|
86
90
|
|
87
91
|
class Decimal < Primitive
|
@@ -90,6 +94,10 @@ module Ohm
|
|
90
94
|
def object
|
91
95
|
::Kernel::BigDecimal(@raw)
|
92
96
|
end
|
97
|
+
|
98
|
+
def type
|
99
|
+
::BigDecimal
|
100
|
+
end
|
93
101
|
end
|
94
102
|
|
95
103
|
class Integer < Primitive
|
@@ -98,6 +106,10 @@ module Ohm
|
|
98
106
|
def object
|
99
107
|
::Kernel::Integer(@raw)
|
100
108
|
end
|
109
|
+
|
110
|
+
def type
|
111
|
+
::Fixnum
|
112
|
+
end
|
101
113
|
end
|
102
114
|
|
103
115
|
class Float < Primitive
|
@@ -106,6 +118,10 @@ module Ohm
|
|
106
118
|
def object
|
107
119
|
::Kernel::Float(@raw)
|
108
120
|
end
|
121
|
+
|
122
|
+
def type
|
123
|
+
::Float
|
124
|
+
end
|
109
125
|
end
|
110
126
|
|
111
127
|
class Time < Primitive
|
@@ -114,6 +130,10 @@ module Ohm
|
|
114
130
|
def object
|
115
131
|
::Time.parse(@raw).utc
|
116
132
|
end
|
133
|
+
|
134
|
+
def type
|
135
|
+
::Time
|
136
|
+
end
|
117
137
|
end
|
118
138
|
|
119
139
|
class Date < Primitive
|
@@ -122,6 +142,10 @@ module Ohm
|
|
122
142
|
def object
|
123
143
|
::Date.parse(@raw)
|
124
144
|
end
|
145
|
+
|
146
|
+
def type
|
147
|
+
::Date
|
148
|
+
end
|
125
149
|
end
|
126
150
|
|
127
151
|
class Boolean
|
@@ -166,6 +190,10 @@ module Ohm
|
|
166
190
|
def respond_to?(method)
|
167
191
|
object.respond_to?(method)
|
168
192
|
end
|
193
|
+
|
194
|
+
def type
|
195
|
+
self.class::RAW
|
196
|
+
end
|
169
197
|
end
|
170
198
|
|
171
199
|
class Hash < Serialized
|
data/test/typecast_array_test.rb
CHANGED
data/test/typecast_date_test.rb
CHANGED
data/test/typecast_float_test.rb
CHANGED
data/test/typecast_hash_test.rb
CHANGED
data/test/typecast_time_test.rb
CHANGED