object_struct 0.0.5 → 0.0.6
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/CHANGELOG +4 -0
- data/lib/object_struct/object_struct.rb +2 -1
- data/test/test_data.json +2 -1
- data/test/test_object_struct.rb +2 -0
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -25,7 +25,7 @@
|
|
25
25
|
# @abstract You probably want to subclass ObjectStruct, to reflect your business
|
26
26
|
# entities. See the README for example use.
|
27
27
|
class ObjectStruct < OpenStruct
|
28
|
-
VERSION = '0.0.
|
28
|
+
VERSION = '0.0.6'
|
29
29
|
|
30
30
|
# Delegated to Hash#each
|
31
31
|
def each &blk
|
@@ -73,6 +73,7 @@ class ObjectStruct < OpenStruct
|
|
73
73
|
def method_missing(name, *args)
|
74
74
|
if name =~ /^has_(\w+)\?$/
|
75
75
|
if respond_to? (field = $1.to_sym)
|
76
|
+
return @table.has_key?(:id) if field == :id # necessary, since all ruby objects have id method
|
76
77
|
result = (send field)
|
77
78
|
if (result.kind_of? Enumerable) && result.respond_to?(:count)
|
78
79
|
(result.count > 0)
|
data/test/test_data.json
CHANGED
data/test/test_object_struct.rb
CHANGED