bound 2.1.1 → 2.1.2.pre.pre1

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: 54b4ed32ea856da58caa09c3199b803daadea9a0
4
- data.tar.gz: bf05f45b4fe4dd8f0ff975d9230e10edb32db1fd
3
+ metadata.gz: ccf90729fbe97e4a62df055bfaf068ac516c55d1
4
+ data.tar.gz: aabc8ce7c1669bc5acbcc4dd8cb4e4aead0477cf
5
5
  SHA512:
6
- metadata.gz: aa99229e9f674deada3272536d2229a49f8fdfb0bddb939191fe58c34845c350265accd612bee7035d39952a7bd1b81b8f7597c182b79b6320e6503361c5ebec
7
- data.tar.gz: edbd4118c85dd704f1a279bec883b911ff982872b5bab20ac7f031a263514d9bc4410a6cebb1ecfe9cc5f23f6446e27b3fc6719d4b9d97aa3f6bb72e8902af6b
6
+ metadata.gz: b38aac9dddb8a78d7e6a0114143810e6c83652e62155dda26417a4abbe80e05a6bc4647e21d42cbc8d1b4da4a4126d169f25f347f4c674d2c0dabb074592d2e6
7
+ data.tar.gz: 14b03a0eda06a6cb6f312c64f24d0219153818aef873e07d693be7859ec847454b8b3472caf82af5f195e4983a37ee200d88fe40f15b1a0bd24a50b66ff6cec8
@@ -239,12 +239,18 @@ class Bound
239
239
  def self.define_delegate(attr, prefix = '')
240
240
  code = <<-EOR
241
241
  def #{prefix}#{attr}
242
- return @o[:#{attr}] if @o && @o.key?(:#{attr})
243
- return @t.kind_of?(Hash) ? @t[:#{attr}] : @t.#{attr} if @t
244
- nil
242
+ if @o && @o.key?(:#{attr})
243
+ @o[:#{attr}]
244
+ elsif @t
245
+ if @t.kind_of?(Hash)
246
+ @t[:#{attr}]
247
+ elsif @t.respond_to?(:#{attr})
248
+ @t.#{attr}
249
+ end
250
+ end
245
251
  end
246
252
  EOR
247
- class_eval code
253
+ class_eval code, __FILE__, __LINE__ - 6
248
254
  end
249
255
 
250
256
  def self.define_nested_delegate(attr, nested_class)
@@ -1,3 +1,3 @@
1
1
  class Bound
2
- VERSION = "2.1.1"
2
+ VERSION = "2.1.2-pre1"
3
3
  end
@@ -366,5 +366,21 @@ describe Bound do
366
366
  end
367
367
  end
368
368
 
369
+ describe 'bug: raises error if optional attribute does not exist in input' do
370
+ Person = Bound.optional(:gender)
371
+
372
+ let(:the_hash) { {} }
373
+ let(:object) { HashObject.new({}) }
374
+
375
+ it 'for object' do
376
+ person = Person.new(object)
377
+ assert_nil person.gender
378
+ end
379
+
380
+ it 'for hash' do
381
+ person = Person.new(the_hash)
382
+ assert_nil person.gender
383
+ end
384
+ end
369
385
 
370
386
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bound
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2.pre.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakob Holderbaum
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-12-16 00:00:00.000000000 Z
12
+ date: 2017-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -106,12 +106,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ">="
109
+ - - ">"
110
110
  - !ruby/object:Gem::Version
111
- version: '0'
111
+ version: 1.3.1
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.5.2
114
+ rubygems_version: 2.5.1
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: Implements a nice helper for fast boundary definitions