object_struct 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.6 (October 4, 2010)
2
+
3
+ Handle has_id? calls by checking table, not ruby object ids
4
+
1
5
  ## 0.0.5 (October 4, 2010)
2
6
 
3
7
  Handle capital letters and numbers in has_property?
@@ -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.5'
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
@@ -12,5 +12,6 @@
12
12
  ],
13
13
  "slotnozzle": {"bar": 25},
14
14
  "foo": {"bar": {"baz": 25}},
15
- "empty_array": []
15
+ "empty_array": [],
16
+ "text": "text property"
16
17
  }
@@ -61,5 +61,7 @@ class ObjectStructTest < MiniTest::Unit::TestCase
61
61
  refute @widget.has_empty_array?
62
62
  refute @widget.has_empty_with_CaPiTaL_lEtTeRs?
63
63
  refute @widget.has_empty_w17h_numb3r5?
64
+ refute @widget.has_id?
65
+ assert @widget.has_text?
64
66
  end
65
67
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 5
9
- version: 0.0.5
8
+ - 6
9
+ version: 0.0.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Quid, Inc.