representable 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +10 -0
- data/lib/representable/config.rb +3 -2
- data/lib/representable/version.rb +1 -1
- data/test/inherit_test.rb +10 -0
- 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: 351c7071b33faa1215070024868b2614288915f4
|
4
|
+
data.tar.gz: 9960a2f4c850764bc48ad3db09c84581fb53049a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae7afd058a763a369761633d3375d865d583e7761988665580c6765980b254dc0443cdc3c3b641a5de3f94476f2cecaa23550dc3bc72c0f10e9b2d215fb6c269
|
7
|
+
data.tar.gz: f44ba7ec3298e2d264be42f491561a00dbb1375a3ff347848abdb4ab5a87d603ad86a1f513721752b48864204be89e2fd5ce512b068d5fc0c183c7c1b0aef106
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# 2.1.5
|
2
|
+
|
3
|
+
* Using `inherit: true` now works even if the parent property hasn't been defined before. It will simply create a new property. This used to crash with `undefined method `merge!' for nil:NilClass`.
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
class SongRepresenter < Representable::Decorator
|
7
|
+
property :title, inherit: true # this will create a brand-new :title property.
|
8
|
+
end
|
9
|
+
```
|
10
|
+
|
1
11
|
# 2.1.4
|
2
12
|
|
3
13
|
* Allow lonely collection representers without configuration, with inline representer, only. This is for render-only collection representers and very handy.
|
data/lib/representable/config.rb
CHANGED
@@ -28,9 +28,10 @@ module Representable
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def add(name, options, &block)
|
31
|
-
if options[:inherit] # i like that: the :inherit shouldn't be handled outside.
|
32
|
-
return
|
31
|
+
if options[:inherit] and parent_property = get(name) # i like that: the :inherit shouldn't be handled outside.
|
32
|
+
return parent_property.merge!(options, &block)
|
33
33
|
end
|
34
|
+
options.delete(:inherit) # TODO: can we handle the :inherit in one single place?
|
34
35
|
|
35
36
|
self[name.to_s] = definition_class.new(name, options, &block)
|
36
37
|
end
|
data/test/inherit_test.rb
CHANGED
@@ -115,6 +115,16 @@ class InheritTest < MiniTest::Spec
|
|
115
115
|
it { inheriting.new(OpenStruct.new(:hit => OpenStruct.new(:title => "Hole In Your Soul", :length => "2:59"))).to_hash.must_equal(
|
116
116
|
{"hit"=>{"title"=>"Hole In Your Soul", "length"=>"2:59"}}) }
|
117
117
|
end
|
118
|
+
|
119
|
+
|
120
|
+
# :inherit when property doesn't exist, yet.
|
121
|
+
describe ":inherit without inheritable property" do
|
122
|
+
representer! do
|
123
|
+
property :name, :inherit => true
|
124
|
+
end
|
125
|
+
|
126
|
+
it { representer.prepare(Song.new("The Beginning")).to_hash.must_equal({"name"=>"The Beginning"})}
|
127
|
+
end
|
118
128
|
end
|
119
129
|
|
120
130
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: representable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|