Class: AD::Framework::Utilities::Transaction
- Inherits:
-
Object
- Object
- AD::Framework::Utilities::Transaction
- Defined in:
- lib/ad-framework/utilities/transaction.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#callbacks ⇒ Object
Returns the value of attribute callbacks.
-
#entry ⇒ Object
Returns the value of attribute entry.
Instance Method Summary collapse
-
#initialize(action, entry, &block) ⇒ Transaction
constructor
A new instance of Transaction.
- #run ⇒ Object
Constructor Details
#initialize(action, entry, &block) ⇒ Transaction
Returns a new instance of Transaction.
8 9 10 11 12 |
# File 'lib/ad-framework/utilities/transaction.rb', line 8 def initialize(action, entry, &block) self.entry = entry self.callbacks = (self.entry.schema.callbacks[action.to_sym] || {}) self.block = block end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
6 7 8 |
# File 'lib/ad-framework/utilities/transaction.rb', line 6 def block @block end |
#callbacks ⇒ Object
Returns the value of attribute callbacks.
6 7 8 |
# File 'lib/ad-framework/utilities/transaction.rb', line 6 def callbacks @callbacks end |
#entry ⇒ Object
Returns the value of attribute entry.
6 7 8 |
# File 'lib/ad-framework/utilities/transaction.rb', line 6 def entry @entry end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 |
# File 'lib/ad-framework/utilities/transaction.rb', line 14 def run self.run_callbacks(self.callbacks[:before]) self.entry.instance_eval(&self.block) self.run_callbacks(self.callbacks[:after]) end |