attribution 0.6.1 → 0.6.2

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.
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.6.1"
5
+ gem.version = "0.6.2"
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.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
data/lib/attribution.rb CHANGED
@@ -209,7 +209,7 @@ module Attribution
209
209
 
210
210
  # TODO: Support a more generic version of lazy-loading
211
211
  begin
212
- association_class = association_name.to_s.singularize.classify.constantize
212
+ association_class = association_name.to_s.classify.constantize
213
213
  rescue NameError => ex
214
214
  raise ArgumentError.new("Association #{association_name} in #{self.class} is invalid because #{association_name.to_s.classify} does not exist")
215
215
  end
@@ -232,7 +232,7 @@ module Attribution
232
232
  define_method("#{association_name}=") do |arg|
233
233
  # TODO: put this in method
234
234
  begin
235
- association_class = association_name.to_s.singularize.classify.constantize
235
+ association_class = association_name.to_s.classify.constantize
236
236
  rescue NameError => ex
237
237
  raise ArgumentError.new("Association #{association_name} in #{self.class} is invalid because #{association_name.to_s.classify} does not exist")
238
238
  end
@@ -1,6 +1,19 @@
1
1
  require 'test_helper'
2
2
 
3
3
  #TODO: support using a different class name than the association name
4
+
5
+ class Address
6
+ include Attribution
7
+
8
+ integer :id
9
+ string :street
10
+ string :city
11
+ string :state
12
+ string :zip
13
+
14
+ belongs_to :author
15
+ end
16
+
4
17
  class Author
5
18
  include Attribution
6
19
 
@@ -8,6 +21,7 @@ class Author
8
21
  string :first_name
9
22
  string :last_name
10
23
 
24
+ has_many :addresses
11
25
  has_many :books
12
26
  end
13
27
 
@@ -220,4 +234,9 @@ class AttributionTest < Test::Unit::TestCase
220
234
  assert_equal nil, JSON.parse(book.to_json)['foo']
221
235
  assert JSON.parse(book.to_json).key?('title'), 'to_json sohuld include attributes that have no value assigned to them'
222
236
  end
237
+
238
+ def test_has_many_association_name
239
+ author = Author.new(addresses: [{id: 1}])
240
+ assert_equal [1], author.addresses.map(&:id)
241
+ end
223
242
  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.6.1
4
+ version: 0.6.2
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-30 00:00:00.000000000 Z
12
+ date: 2013-05-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
- rubygems_version: 1.8.24
105
+ rubygems_version: 1.8.25
106
106
  signing_key:
107
107
  specification_version: 3
108
108
  summary: Add attributes to Ruby objects
@@ -110,4 +110,3 @@ test_files:
110
110
  - test/attribution_model_test.rb
111
111
  - test/attribution_test.rb
112
112
  - test/test_helper.rb
113
- has_rdoc: