blobject 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 708992c07f068c79b12ba29d62268cdf002e0eb2
4
- data.tar.gz: bbeef31664ae8ab9dced3e8db1ea2ccb06f26f41
3
+ metadata.gz: 2c7c862a83d86e0593b9001b7230fa361cd7b13f
4
+ data.tar.gz: 2219dc72d2f80c9004c8489f33d4772d82286dc6
5
5
  SHA512:
6
- metadata.gz: bdafb48ddfdb1bffd175e7374b4a19e27ac0de26fae8e0f654ccf12768057a2a8069425eb2fc3d8a24e77525897dea0f9a1b07a1d53c2d31a29e66345c965cdb
7
- data.tar.gz: 5c474f2ec4bb07a7090f23641763d490fdac826a0ed009594410e149eac2951d60e2398c9ac351ebc965465209860dfcfbb467054e24a7816e827ac827733241
6
+ metadata.gz: a0f6b8c6af581fc4ae3adeba3320621fc033393f6362171a01241c8c051c4b68e7a9162e8a6696068bc25f5f5243aa267a50180fd0f83751bf908e334fc55ae6
7
+ data.tar.gz: 11f5c2466cf946bb37791a150e442168bb28e69580108ae3c6717358251957e81cb9414ff6319f3c56977c2d5563804341bce17e7d50a97b6f0f83b59c9d63e3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blobject (0.4.0)
4
+ blobject (0.4.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,6 +1,6 @@
1
- ![](https://github.com/sjltaylor/blobject/raw/master/assets/blobject.png)
1
+ ![](https://github.com/sjltaylor/blobject/raw/master/assets/blobject.png)
2
2
 
3
- Rdocs: [http://sjltaylor.github.com/blobject](http://sjltaylor.github.com/blobject)
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
  ![](https://github.com/sjltaylor/blobject/raw/master/assets/blob_defn.png)
271
-
@@ -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) if value.is_a?(Hash) or value.is_a?(Array)
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
- @hash[name] = value unless frozen?
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
@@ -1,4 +1,4 @@
1
1
  class Blobject
2
2
  # semver gem version
3
- VERSION = '0.4.0'
3
+ VERSION = '0.4.1'
4
4
  end
@@ -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
@@ -1,7 +1,5 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
- require 'ruby-debug' if ARGV.include? 'debug'
4
-
5
3
  $:.push '.'
6
4
 
7
- Dir['./spec/**/*_spec.rb'].each { |test_file| require test_file }
5
+ Dir['./spec/**/*_spec.rb'].each { |test_file| require test_file }
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.0
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-26 00:00:00.000000000 Z
11
+ date: 2014-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest