Class: Shale::Mapping::Delegates Private
- Inherits:
-
Object
- Object
- Shale::Mapping::Delegates
- Defined in:
- lib/shale/mapping/delegates.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class for handling attribute delegation
Defined Under Namespace
Classes: Delegate
Instance Method Summary collapse
-
#add(receiver_attribute, setter, value) ⇒ Object
private
Add single value to delegate.
-
#add_collection(receiver_attribute, setter, value) ⇒ Object
private
Add collection to delegate.
-
#each(&block) ⇒ Object
private
Iterate over delegates and yield a block.
-
#initialize ⇒ Delegates
constructor
private
Initialize instance.
Constructor Details
#initialize ⇒ Delegates
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize instance
51 52 53 |
# File 'lib/shale/mapping/delegates.rb', line 51 def initialize @delegates = [] end |
Instance Method Details
#add(receiver_attribute, setter, value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Add single value to delegate
62 63 64 |
# File 'lib/shale/mapping/delegates.rb', line 62 def add(receiver_attribute, setter, value) @delegates << Delegate.new(receiver_attribute, setter, value) end |
#add_collection(receiver_attribute, setter, value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Add collection to delegate
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/shale/mapping/delegates.rb', line 73 def add_collection(receiver_attribute, setter, value) delegate = @delegates.find do |e| e.receiver_attribute == receiver_attribute && e.setter == setter end if delegate delegate.value << value else @delegates << Delegate.new(receiver_attribute, setter, [value]) end end |
#each(&block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Iterate over delegates and yield a block
90 91 92 |
# File 'lib/shale/mapping/delegates.rb', line 90 def each(&block) @delegates.each(&block) end |