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 +4 -4
- data/lib/bound.rb +10 -4
- data/lib/bound/version.rb +1 -1
- data/spec/bound_spec.rb +16 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccf90729fbe97e4a62df055bfaf068ac516c55d1
|
4
|
+
data.tar.gz: aabc8ce7c1669bc5acbcc4dd8cb4e4aead0477cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b38aac9dddb8a78d7e6a0114143810e6c83652e62155dda26417a4abbe80e05a6bc4647e21d42cbc8d1b4da4a4126d169f25f347f4c674d2c0dabb074592d2e6
|
7
|
+
data.tar.gz: 14b03a0eda06a6cb6f312c64f24d0219153818aef873e07d693be7859ec847454b8b3472caf82af5f195e4983a37ee200d88fe40f15b1a0bd24a50b66ff6cec8
|
data/lib/bound.rb
CHANGED
@@ -239,12 +239,18 @@ class Bound
|
|
239
239
|
def self.define_delegate(attr, prefix = '')
|
240
240
|
code = <<-EOR
|
241
241
|
def #{prefix}#{attr}
|
242
|
-
|
243
|
-
|
244
|
-
|
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)
|
data/lib/bound/version.rb
CHANGED
data/spec/bound_spec.rb
CHANGED
@@ -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.
|
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:
|
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:
|
111
|
+
version: 1.3.1
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.5.
|
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
|