Class: Transacted::Action
- Inherits:
-
Object
- Object
- Transacted::Action
- Defined in:
- lib/transacted/action.rb
Instance Method Summary collapse
- #are_procs?(proc_or_procs) ⇒ Boolean
- #down ⇒ Object
-
#initialize(options) ⇒ Action
constructor
A new instance of Action.
- #up ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Action
Returns a new instance of Action.
3 4 5 6 7 |
# File 'lib/transacted/action.rb', line 3 def initialize raise "Must be initialized with procs" if not are_procs? [[:up], [:down]] @up = [:up] @down = [:down] end |
Instance Method Details
#are_procs?(proc_or_procs) ⇒ Boolean
21 22 23 24 |
# File 'lib/transacted/action.rb', line 21 def are_procs? proc_or_procs procs = [*proc_or_procs] procs.all? { |proc| proc.is_a?(Proc)} end |
#down ⇒ Object
13 14 15 |
# File 'lib/transacted/action.rb', line 13 def down return @down.call end |
#up ⇒ Object
9 10 11 |
# File 'lib/transacted/action.rb', line 9 def up return @up.call end |
#valid? ⇒ Boolean
17 18 19 |
# File 'lib/transacted/action.rb', line 17 def valid? are_procs? [@up,@down] end |