ohm-contrib 0.0.34 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/ohm/contrib.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Ohm
2
2
  module Contrib
3
- VERSION = '0.0.34'
3
+ VERSION = '0.0.35'
4
4
  end
5
5
 
6
6
  autoload :Boundaries, "ohm/contrib/boundaries"
@@ -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
@@ -152,3 +152,8 @@ test "inspecting" do
152
152
  assert %{"\\\"FooBar\\\""} == post.addresses.inspect
153
153
  end
154
154
 
155
+ test "type is array" do
156
+ post = Post.create(:addresses => ["address1"])
157
+
158
+ assert post.addresses.type == Array
159
+ end
@@ -75,3 +75,8 @@ test "inspecting" do
75
75
  assert '"FooBar"' == post.created_on.inspect
76
76
  end
77
77
 
78
+ test "type is Date" do
79
+ post = Post.create(:created_on => Date.new(2010, 5, 5))
80
+ assert Date == post.created_on.type
81
+ end
82
+
@@ -75,3 +75,8 @@ test "inspecting a Decimal" do
75
75
  assert '"FooBar"' == post.price.inspect
76
76
  end
77
77
 
78
+ test "type is BigDecimal" do
79
+ post = Post.new(:price => 399.50)
80
+ assert BigDecimal == post.price.type
81
+ end
82
+
@@ -50,3 +50,8 @@ test "inspecting" do
50
50
  assert '"FooBar"' == post.price.inspect
51
51
  end
52
52
 
53
+ test "type is Float" do
54
+ post = Post.new(:price => 399.50)
55
+ assert Float == post.price.type
56
+ end
57
+
@@ -115,3 +115,8 @@ test "inspecting" do
115
115
  assert %{"\\\"FooBar\\\""} == post.address.inspect
116
116
  end
117
117
 
118
+ test "type is Hash" do
119
+ post = Post.new(:address => { "address1" => "#456" })
120
+ assert Hash == post.address.type
121
+ end
122
+
@@ -64,3 +64,8 @@ test "inspecting" do
64
64
  assert '"FooBar"' == post.price.inspect
65
65
  end
66
66
 
67
+ test "type is Fixnum" do
68
+ post = Post.new(:price => 399)
69
+ assert Fixnum == post.price.type
70
+ end
71
+
@@ -36,3 +36,7 @@ test "inspecting" do
36
36
  assert 'FooBar' == post.content
37
37
  end
38
38
 
39
+ test "type is String" do
40
+ post = Post.new(:content => "FooBar")
41
+ assert String == post.content.type
42
+ end
@@ -65,3 +65,8 @@ test "inspecting" do
65
65
  assert '"FooBar"' == post.created_at.inspect
66
66
  end
67
67
 
68
+ test "type is Time" do
69
+ post = Post.create(:created_at => Time.utc(2010, 05, 05))
70
+ assert Time == post.created_at.type
71
+ end
72
+
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 34
9
- version: 0.0.34
8
+ - 35
9
+ version: 0.0.35
10
10
  platform: ruby
11
11
  authors:
12
12
  - Cyril David