Class: Undestroy::Transfer
- Inherits:
-
Object
- Object
- Undestroy::Transfer
- Defined in:
- lib/undestroy/transfer.rb
Instance Attribute Summary collapse
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Transfer
constructor
A new instance of Transfer.
- #run ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Transfer
Returns a new instance of Transfer.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/undestroy/transfer.rb', line 5 def initialize(args={}) raise ArgumentError, ":klass option required" unless args[:klass] args[:fields] ||= {} self.target = args[:target] || args[:klass].new # Set instance values directly to avoid AR's filtering of protected fields args[:fields].each do |field, value| self.target[field] = value end end |
Instance Attribute Details
#target ⇒ Object
Returns the value of attribute target.
3 4 5 |
# File 'lib/undestroy/transfer.rb', line 3 def target @target end |
Instance Method Details
#run ⇒ Object
17 18 19 |
# File 'lib/undestroy/transfer.rb', line 17 def run self.target.save end |