praxis-mapper 4.4.1 → 4.5

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
  SHA256:
3
- metadata.gz: 02ce194e017bb5f707f99d4c7cf8df5af4942fa7826ebe23796505190e87373f
4
- data.tar.gz: 844f88dc837c2350de675e01f3507189be0c9ed5c34641389d7317e2f7ebb04a
3
+ metadata.gz: 0006c7fa042540a90f59a1b0b5c46970a65992c784ec1aada8b277565065d3cd
4
+ data.tar.gz: 528bfc8868e9f5398dcc235ca6736d6c767fba72a0fdba114be21d03cd50105f
5
5
  SHA512:
6
- metadata.gz: '0850b69a930888858fa430d57acf1fdd8ac4a4142b27759d668dd90bf6ac1f425bed9593a0b7e06ed2f9db3f8b9487436b0e57925c3a2a8485293890eeb9f27a'
7
- data.tar.gz: ce11282124a380f3dc0fe4ab7b6adfbc4a6b7e5691b0cd58339bee15e4c751b3a894259c169b25052d5c013d78d484b6e73ad5b950e57ebb19c752cd2a69e14d
6
+ metadata.gz: 528e131bae155211ecce7a8d6accd9296ecad5765e69988e32093712db6bd104839d23abfe86117907d12aa023b032d87bb847d8a7834fa6d041bb1dff472025
7
+ data.tar.gz: 79cd448c7622c39ca626147fec68b24f2e9273947542c497d65b4a4290a428fcc52d33704bee00fb5fa0a5a14e47a986a9f9bf731fbd35410dee4911b16fde14
@@ -1,5 +1,9 @@
1
1
  # praxis-mapper changelog
2
2
 
3
+ ## 4.5 (6/25/2019)
4
+
5
+ * Support wrapping associations in resources for targets that do not explicitly contain the `Enumerable` module. For example, `ActiveRecord::Associations::CollectionProxy` are actually not enumerable, yet they proxy the calls directly to the underlying objects when necessary.
6
+
3
7
  ## 4.4.1 (6/25/2019)
4
8
 
5
9
  * Fix `Resource` to not override association methods already defined
@@ -145,11 +145,12 @@ module Praxis::Mapper
145
145
 
146
146
 
147
147
  def self.wrap(records)
148
- case records
149
- when nil
148
+ if records.nil?
150
149
  return []
151
- when Enumerable
152
- return records.compact.collect { |record| self.for_record(record) }
150
+ elsif( records.is_a?(Enumerable) )
151
+ return records.compact.map { |record| self.for_record(record) }
152
+ elsif ( records.respond_to?(:to_a) )
153
+ return records.to_a.compact.map { |record| self.for_record(record) }
153
154
  else
154
155
  return self.for_record(records)
155
156
  end
@@ -1,5 +1,5 @@
1
1
  module Praxis
2
2
  module Mapper
3
- VERSION = "4.4.1"
3
+ VERSION = "4.5"
4
4
  end
5
5
  end
@@ -200,6 +200,14 @@ describe Praxis::Mapper::Resource do
200
200
  wrapped_set.should be_kind_of(Array)
201
201
  wrapped_set.length.should be(1)
202
202
  end
203
+
204
+ it 'works with non-enumerable objects, that respond to collect' do
205
+ collectable = double("ArrayProxy")
206
+ collectable.stub(:to_a) { [record, record] }
207
+
208
+ wrapped_set = SimpleResource.wrap(collectable)
209
+ wrapped_set.length.should be(2)
210
+ end
203
211
 
204
212
  it 'works regardless of the resource class used' do
205
213
  SimpleResource.wrap(record).should be(OtherResource.wrap(record))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: praxis-mapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.1
4
+ version: '4.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep M. Blanquer