attribution 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/attribution.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "attribution"
5
- gem.version = "0.5.0"
5
+ gem.version = "0.5.1"
6
6
  gem.authors = ["Paul Barry"]
7
7
  gem.email = ["mail@paulbarry.com"]
8
8
  gem.description = %q{Add attributes to Ruby objects}
@@ -1,3 +1,3 @@
1
1
  module Attribution
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
data/lib/attribution.rb CHANGED
@@ -233,7 +233,7 @@ module Attribution
233
233
  raise ArgumentError.new("Association #{association_name} in #{self.class} is invalid because #{association_name.to_s.classify} does not exist")
234
234
  end
235
235
 
236
- objs = Array(arg).map do |obj|
236
+ objs = (arg.is_a?(Hash) ? arg.values : Array(arg)).map do |obj|
237
237
  o = association_class.cast(obj)
238
238
  o.send("#{self.class.name.underscore}=", self)
239
239
  o.send("#{self.class.name.underscore}_id=", id)
@@ -205,4 +205,8 @@ class AttributionTest < Test::Unit::TestCase
205
205
  assert_equal BigDecimal.new("50"), book.price
206
206
  assert_equal nil, book.id
207
207
  end
208
+
209
+ def test_has_many_setter_with_hash
210
+ assert_equal(["test"], Book.new("chapters" => { "0" => { "title" => "test" }}).chapters.map(&:title))
211
+ end
208
212
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attribution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-04 00:00:00.000000000 Z
12
+ date: 2013-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport