attribute_delegator 0.0.1 → 0.0.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.
@@ -11,6 +11,7 @@ module AttributeDelegator
11
11
 
12
12
  exists_method = :"ensure_#{the_delegate}_exists"
13
13
  define_method exists_method do
14
+ return if self.send(the_delegate)
14
15
  build_method = "build_#{the_delegate.to_s}"
15
16
  self.send(build_method.to_sym)
16
17
  end
@@ -1,3 +1,3 @@
1
1
  module AttributeDelegator
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -14,7 +14,7 @@ end
14
14
 
15
15
  class TestAttributeDelegator < Test::Unit::TestCase
16
16
  def setup
17
- @entry = Entry.create!(:title => "Entry Title", :body => "Body of entry")
17
+ @entry = Entry.create!(:title => "Entry Title")
18
18
  end
19
19
 
20
20
  def test_delegated_attributes_getters_and_setters
@@ -6,7 +6,7 @@ class Entry < ActiveRecord::Base
6
6
  delegates_attributes_to :entry_metadata, [:page_views]
7
7
 
8
8
  has_one :entry_photo
9
- delegates_attributes_to :entry_photo, [:photo]
9
+ delegates_attributes_to :entry_photo, [:format, :photo]
10
10
  end
11
11
 
12
12
  class EntryMetadata < ActiveRecord::Base
@@ -21,16 +21,13 @@ end
21
21
 
22
22
 
23
23
  class TestMultipleAttributeDelegators < Test::Unit::TestCase
24
- def setup
25
- @entry = Entry.create!(:title => "Entry Title", :body => "Body of entry")
26
- end
27
-
28
24
  def test_working_with_multiple_delegates
29
25
  page_views = 10
30
26
  photo = "ok pretend this string is a photo"
31
27
  e = Entry.create!({
32
28
  :page_views => page_views,
33
- :photo => photo
29
+ :photo => photo,
30
+ :format => 'jpeg'
34
31
  })
35
32
  assert_equal photo, e.photo
36
33
  assert_equal photo, e.entry_photo.photo
@@ -13,7 +13,6 @@ ActiveRecord::Base.establish_connection({
13
13
  ActiveRecord::Schema.define do
14
14
  create_table "entries", :force => true do |t|
15
15
  t.column "title", :string
16
- t.column "body", :text
17
16
  end
18
17
 
19
18
  create_table "entry_metadata", :force => true do |t|
@@ -23,6 +22,7 @@ ActiveRecord::Schema.define do
23
22
 
24
23
  create_table "entry_photos", :force => true do |t|
25
24
  t.column "entry_id", :integer
26
- t.column "photo", :text
25
+ t.column "photo", :text, :null => false
26
+ t.column "format", :string, :null => false
27
27
  end
28
28
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attribute_delegator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Clif Reeder