representable 2.0.3 → 2.0.4

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: 01a2c225e9cbfbb8c74843a07cac6d0616e8ea56
4
- data.tar.gz: 8715c50c8f493f93d4a94a724001665a250bd91d
3
+ metadata.gz: 9ae87cf0d1e79ff26480467bc624e3df5633e2b5
4
+ data.tar.gz: f46dd9c54daa7efb76af07add37e17780fb81b59
5
5
  SHA512:
6
- metadata.gz: 6883f8f9f7fcee4931b23ceb8b28794260c17a97ba5594a5bbea1dffc92224c1711f95e4a8e7df339e6a6b0a9929740b9de1edfa8de4d22e2e765c130a16db3c
7
- data.tar.gz: 7c825c62ad5ba9103400edda45494e128eb53f901ad57cb8ae9190e0c974a8f78e9e49cfa340dad2d351f2fd564e83fa8c5dd3bdaae41aa0d40543588522ae2f
6
+ metadata.gz: 77511aff2f7d3d88a31c29b4feeec1d4b2c4dd31ec612a3c7521994007adcef4541b89ed14bf54338e796f539023b2cb6cbefc40efe71c7699c30d720c81bcce
7
+ data.tar.gz: 1983166eda318f1a45cbb349707aae61e2482952e9c29143a5791c6384ed9d4e7cfd1b0efc3a2d6ef083d9626e16e56aef9c6e857ad118775dbbe2d1d4e1859c
data/CHANGES.md CHANGED
@@ -1,6 +1,11 @@
1
+ # 2.0.4
2
+
3
+ * Fix implicit rendering of JSON and XML collections where json/collection wasn't loaded properly, resulting in the native JSON's `#to_json` to be called.
4
+ * Fix `:find_or_instantiate` parse strategy which wouldn't instantiate but raise an error. Thanks to @d4rky-pl.
5
+
1
6
  # 2.0.3
2
7
 
3
- # Fixed a bug where `Forwardable` wasn't available (because we didn't require it :).
8
+ * Fixed a bug where `Forwardable` wasn't available (because we didn't require it :).
4
9
 
5
10
  # 2.0.2
6
11
 
@@ -14,6 +14,7 @@ module Representable
14
14
 
15
15
  include Representable # include after class methods so Decorator::prepare can't be overwritten by Representable::prepare.
16
16
 
17
+ # TODO: implement that just by calling ::property(name, options){include mod} on the inheriting representer.
17
18
  module InheritModule
18
19
  def inherit_module!(parent)
19
20
  inherited_attrs = parent.representable_attrs[:definitions].keys
@@ -1,5 +1,6 @@
1
1
  require 'multi_json'
2
2
  require 'representable/hash'
3
+ require 'representable/json/collection'
3
4
 
4
5
  module Representable
5
6
  # Brings #to_json and #from_json to your object.
@@ -50,9 +50,9 @@ module Representable
50
50
  args = args.last # TODO: don't pass i as separate block parameter but in Options.
51
51
  object_class = args.binding[:class].evaluate(self, fragment, args)
52
52
 
53
- object_class.find(fragment["id"]) or object_class.new
53
+ object_class.find_by(id: fragment["id"]) or object_class.new
54
54
  }
55
55
  end
56
56
  end
57
57
  end
58
- end
58
+ end
@@ -1,3 +1,3 @@
1
1
  module Representable
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.4"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require 'representable'
2
2
  require 'representable/bindings/xml_bindings'
3
+ require 'representable/xml/collection'
3
4
  require 'nokogiri'
4
5
 
5
6
  module Representable
@@ -1,6 +1,5 @@
1
1
  require 'test_helper'
2
2
 
3
- require 'representable/json/collection'
4
3
  require 'representable/json/hash'
5
4
 
6
5
  class LonelyRepresenterTest < MiniTest::Spec
@@ -145,8 +145,8 @@ class ParseStrategyFindOrInstantiateTest < BaseTest
145
145
 
146
146
  Song = Struct.new(:id, :title)
147
147
  Song.class_eval do
148
- def self.find(id)
149
- return new(1, "Resist Stan") if id==1# we should return the same object here
148
+ def self.find_by(attributes={})
149
+ return new(1, "Resist Stan") if attributes[:id]==1# we should return the same object here
150
150
  new
151
151
  end
152
152
  end
@@ -227,8 +227,8 @@ end
227
227
  class ParseStrategyLambdaTest < MiniTest::Spec
228
228
  Song = Struct.new(:id, :title)
229
229
  Song.class_eval do
230
- def self.find(id)
231
- return new(1, "Resist Stan") if id==1# we should return the same object here
230
+ def self.find_by(attributes={})
231
+ return new(1, "Resist Stan") if attributes[:id]==1# we should return the same object here
232
232
  new
233
233
  end
234
234
  end
@@ -276,4 +276,4 @@ class ParseStrategyLambdaTest < MiniTest::Spec
276
276
 
277
277
  # TODO: test with existing collection
278
278
  end
279
- end
279
+ end
@@ -378,7 +378,6 @@ class CollectionTest < MiniTest::Spec
378
378
  end
379
379
  end
380
380
 
381
- require 'representable/xml/collection'
382
381
  require 'representable/xml/hash'
383
382
  class LonelyRepresenterTest < MiniTest::Spec
384
383
  # TODO: where is the XML::Hash test?
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.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-31 00:00:00.000000000 Z
11
+ date: 2014-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -260,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
260
  version: '0'
261
261
  requirements: []
262
262
  rubyforge_project:
263
- rubygems_version: 2.2.2
263
+ rubygems_version: 2.2.1
264
264
  signing_key:
265
265
  specification_version: 4
266
266
  summary: Renders and parses JSON/XML/YAML documents from and to Ruby objects. Includes
@@ -308,3 +308,4 @@ test_files:
308
308
  - test/xml_bindings_test.rb
309
309
  - test/xml_test.rb
310
310
  - test/yaml_test.rb
311
+ has_rdoc: