Class: PassAlong
- Inherits:
-
Object
- Object
- PassAlong
- Defined in:
- lib/husky/pass_along.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#receiver ⇒ Object
readonly
Returns the value of attribute receiver.
-
#sender ⇒ Object
readonly
Returns the value of attribute sender.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(sender, receiver, method) ⇒ PassAlong
constructor
A new instance of PassAlong.
- #run ⇒ Object
Constructor Details
#initialize(sender, receiver, method) ⇒ PassAlong
Returns a new instance of PassAlong.
11 12 13 14 15 |
# File 'lib/husky/pass_along.rb', line 11 def initialize(sender, receiver, method) @sender = sender @receiver = receiver @method = method end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
9 10 11 |
# File 'lib/husky/pass_along.rb', line 9 def method @method end |
#receiver ⇒ Object (readonly)
Returns the value of attribute receiver.
9 10 11 |
# File 'lib/husky/pass_along.rb', line 9 def receiver @receiver end |
#sender ⇒ Object (readonly)
Returns the value of attribute sender.
9 10 11 |
# File 'lib/husky/pass_along.rb', line 9 def sender @sender end |
Class Method Details
.all_variables(sender, receiver) ⇒ Object
3 4 5 6 7 |
# File 'lib/husky/pass_along.rb', line 3 def self.all_variables(sender, receiver) sender.class.instance_methods(false).each do |method| new(sender, receiver, method).run end end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/husky/pass_along.rb', line 17 def run sender.class.after method do |*, obj| variables = get_variables_from(sender) variables.each do |var| receiver.instance_variable_set(var, sender.instance_variable_get(var)) end end end |