representable 2.1.7 → 2.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89001d90401ddb1d037e061a528599b5a5766a9a
4
- data.tar.gz: e7035bf1405dbb411f4daee3aa8bdfb499d8bb3f
3
+ metadata.gz: 1474ed4afb6124795809e52491554dd58a2e13aa
4
+ data.tar.gz: 60f358588f53073142fd022959f6f5994b64a3cc
5
5
  SHA512:
6
- metadata.gz: 619b6f1015ba1af6a6047864512d39b7f2d0d1b3e237e6124f2967c8fa0dadecef7f0ccd10ce065c1a9b18455fcb09c2ce91e0ab3da5e1417a527f9de0bf4f6b
7
- data.tar.gz: 4bcf5e4dae36a937aa1dcba0908ac7dcbd575438c6c8ad0bd92aa011eaa49cb8aa36d4b33f99039713aed14b07b5fa2a564ec06aea6546fa5695f6056c2e77a8
6
+ metadata.gz: 1c242eac1d5b71200bfe7c67be8bacb9ef5f40431af318e2ce65d4b04a8626ce2f6f1fd2dbdf64844b96588adbd341b1d398ff4e4297190cf74b8db82590d46e
7
+ data.tar.gz: a812ee6f07deff92f515d41fa185c40a45f00e83c37ff5df71c517aeddc834ec643ab79ff4a2e974fba22014cd60744545b8c2a38590521f19a1f6cef62d4959
data/CHANGES.md CHANGED
@@ -1,3 +1,19 @@
1
+ # 2.1.8
2
+
3
+ * API change: features are now included into inline representers in the order they were specified. This used to be the other way round and is, of course, wrong, in case a sub-feature wants to override an existing method introduced by an earlier feature.
4
+
5
+ ```ruby
6
+ class Album < Representable::Decorator
7
+ include Representable::Hash
8
+ feature Title
9
+ feature Date
10
+
11
+ property :songs
12
+ # will include R::Hash, Title, then Date.
13
+ ```
14
+
15
+ As this is an edge-casey change, I decided _not_ to minor-version bump.
16
+
1
17
  # 2.1.7
2
18
 
3
19
  * Adding `Object#to_object`. This is even faster than using `#from_object` for simple transformations.
@@ -76,7 +76,7 @@ module Representable
76
76
  def inline_representer_for(base, features, name, options, &block)
77
77
  representer = options[:use_decorator] ? Decorator : self
78
78
 
79
- representer.build_inline(base, features.reverse, name, options, &block)
79
+ representer.build_inline(base, features, name, options, &block)
80
80
  end
81
81
 
82
82
  def build_config
@@ -1,3 +1,3 @@
1
1
  module Representable
2
- VERSION = "2.1.7"
2
+ VERSION = "2.1.8"
3
3
  end
@@ -38,4 +38,33 @@ class FeaturesTest < MiniTest::Spec
38
38
 
39
39
  it { representer.new(song).to_hash.must_equal({"title"=>"Is It A Lie", "length"=>"2:31", "details"=>{"title"=>"Is It A Lie"}}) }
40
40
  end
41
+ end
42
+
43
+ class FeatureInclusionOrderTest < MiniTest::Spec
44
+ module Title
45
+ def title
46
+ "I was first!"
47
+ end
48
+ end
49
+
50
+ module OverridingTitle
51
+ def title
52
+ "I am number two, " + super
53
+ end
54
+ end
55
+
56
+ representer!(decorator: true) do
57
+ feature Title
58
+ feature OverridingTitle
59
+
60
+ property :title, exec_context: :decorator
61
+
62
+ property :song do
63
+ property :title, exec_context: :decorator
64
+ end
65
+ end
66
+
67
+ it do
68
+ representer.new(OpenStruct.new(song: Object)).to_hash.must_equal({"title"=>"I am number two, I was first!", "song"=>{"title"=>"I am number two, I was first!"}})
69
+ end
41
70
  end
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.7
4
+ version: 2.1.8
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-05-07 00:00:00.000000000 Z
11
+ date: 2015-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -277,52 +277,4 @@ signing_key:
277
277
  specification_version: 4
278
278
  summary: Renders and parses JSON/XML/YAML documents from and to Ruby objects. Includes
279
279
  plain properties, collections, nesting, coercion and more.
280
- test_files:
281
- - test/as_test.rb
282
- - test/benchmarking.rb
283
- - test/binding_test.rb
284
- - test/class_test.rb
285
- - test/coercion_test.rb
286
- - test/config/inherit_test.rb
287
- - test/config_test.rb
288
- - test/decorator_scope_test.rb
289
- - test/decorator_test.rb
290
- - test/definition_test.rb
291
- - test/example.rb
292
- - test/examples/object.rb
293
- - test/exec_context_test.rb
294
- - test/features_test.rb
295
- - test/filter_test.rb
296
- - test/for_collection_test.rb
297
- - test/generic_test.rb
298
- - test/getter_setter_test.rb
299
- - test/hash_bindings_test.rb
300
- - test/hash_test.rb
301
- - test/if_test.rb
302
- - test/inherit_test.rb
303
- - test/inheritable_test.rb
304
- - test/inline_test.rb
305
- - test/instance_test.rb
306
- - test/is_representable_test.rb
307
- - test/json_test.rb
308
- - test/lonely_test.rb
309
- - test/mongoid_test.rb
310
- - test/nested_test.rb
311
- - test/object_test.rb
312
- - test/parse_strategy_test.rb
313
- - test/pass_options_test.rb
314
- - test/prepare_test.rb
315
- - test/reader_writer_test.rb
316
- - test/realistic_benchmark.rb
317
- - test/represent_test.rb
318
- - test/representable_test.rb
319
- - test/schema_test.rb
320
- - test/serialize_deserialize_test.rb
321
- - test/skip_test.rb
322
- - test/stringify_hash_test.rb
323
- - test/test_helper.rb
324
- - test/test_helper_test.rb
325
- - test/wrap_test.rb
326
- - test/xml_bindings_test.rb
327
- - test/xml_test.rb
328
- - test/yaml_test.rb
280
+ test_files: []