blobject 0.4.0 → 0.4.1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.markdown +5 -6
- data/lib/blobject.rb +12 -3
- data/lib/blobject/version.rb +1 -1
- data/spec/blobject_spec.rb +5 -0
- data/spec/exec +1 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c7c862a83d86e0593b9001b7230fa361cd7b13f
|
4
|
+
data.tar.gz: 2219dc72d2f80c9004c8489f33d4772d82286dc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0f6b8c6af581fc4ae3adeba3320621fc033393f6362171a01241c8c051c4b68e7a9162e8a6696068bc25f5f5243aa267a50180fd0f83751bf908e334fc55ae6
|
7
|
+
data.tar.gz: 11f5c2466cf946bb37791a150e442168bb28e69580108ae3c6717358251957e81cb9414ff6319f3c56977c2d5563804341bce17e7d50a97b6f0f83b59c9d63e3
|
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-

|
1
|
+

|
2
2
|
|
3
|
-
|
3
|
+
RDocs: [http://sjltaylor.github.com/blobject](http://sjltaylor.github.com/blobject)
|
4
4
|
|
5
5
|
## About
|
6
6
|
|
@@ -36,7 +36,7 @@ Blobject let's you do this (complete code listing, no predefined data structures
|
|
36
36
|
|
37
37
|
|
38
38
|
data = Blobject.from_json HTTParty.get('https://raw.github.com/sjltaylor/blobject/master/spec/sample_data/sample3.json')
|
39
|
-
|
39
|
+
|
40
40
|
full_name = "#{data.calibration.staff.name.first}#{data.calibration.staff.name.middle_initial}#{data.calibration.staff.name.second}".capitalize
|
41
41
|
=> "Calibrator"
|
42
42
|
|
@@ -135,7 +135,7 @@ Consider a configuration object which contains credentials for a third-party api
|
|
135
135
|
endpoint: 'http://services.thirdparty.net/api'
|
136
136
|
|
137
137
|
With a hash, usage looks like this:
|
138
|
-
|
138
|
+
|
139
139
|
CONFIG[:third_party_api][:endpoint]
|
140
140
|
|
141
141
|
With a Blobject, usage looks like this:
|
@@ -168,7 +168,7 @@ Blobjects can be used to easily build complex payloads.
|
|
168
168
|
person = Blobject.new
|
169
169
|
|
170
170
|
person.name = first: 'David', last: 'Platt'
|
171
|
-
|
171
|
+
|
172
172
|
person.address.tap do |address|
|
173
173
|
address.street = "..."
|
174
174
|
address.city = "..."
|
@@ -268,4 +268,3 @@ Copyright (c) 2012 Sam Taylor. See LICENSE.txt for
|
|
268
268
|
further details.
|
269
269
|
|
270
270
|

|
271
|
-
|
data/lib/blobject.rb
CHANGED
@@ -223,7 +223,7 @@ class Blobject
|
|
223
223
|
unless methods.include? setter_name
|
224
224
|
self.send :define_method, setter_name do |value|
|
225
225
|
begin
|
226
|
-
value = self.class.send(:__blobjectify__, value)
|
226
|
+
value = self.class.send(:__blobjectify__, value)
|
227
227
|
@hash[name] = value
|
228
228
|
rescue => ex
|
229
229
|
__tag_and_raise__(ex)
|
@@ -237,9 +237,18 @@ class Blobject
|
|
237
237
|
|
238
238
|
value = @hash[name]
|
239
239
|
|
240
|
-
if value.nil?
|
240
|
+
if value.nil? && !frozen?
|
241
241
|
value = self.class.new
|
242
|
-
|
242
|
+
|
243
|
+
# close the scope for storing call chain
|
244
|
+
parent = self
|
245
|
+
|
246
|
+
store_in_parent = lambda do
|
247
|
+
parent.send "#{name}=", value
|
248
|
+
value.send :remove_instance_variable, :@store_in_parent
|
249
|
+
end
|
250
|
+
|
251
|
+
value.instance_variable_set :@store_in_parent, store_in_parent
|
243
252
|
end
|
244
253
|
|
245
254
|
value
|
data/lib/blobject/version.rb
CHANGED
data/spec/blobject_spec.rb
CHANGED
@@ -38,6 +38,11 @@ describe Blobject do
|
|
38
38
|
assert !b.fish?, 'should not have assigned an empty blobject'
|
39
39
|
end
|
40
40
|
|
41
|
+
it 'does not result in a graph containing empty blobjects when using checkers' do
|
42
|
+
b.fish.food?
|
43
|
+
assert !b.fish?, 'should not have assigned an empty blobject'
|
44
|
+
end
|
45
|
+
|
41
46
|
it 'turns hashes into blobjects when assigning' do
|
42
47
|
|
43
48
|
b.name = { christian: "Vinnie", surname: "Jones" }
|
data/spec/exec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blobject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Taylor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04
|
11
|
+
date: 2014-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|