Class: Dry::Transaction::Callable Private
- Inherits:
-
Object
- Object
- Dry::Transaction::Callable
- Defined in:
- lib/dry/transaction/callable.rb
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.
Instance Attribute Summary collapse
- #arity ⇒ Object readonly private
- #operation ⇒ Object readonly private
Class Method Summary collapse
- .[](callable) ⇒ Object private
Instance Method Summary collapse
- #call(*args, &block) ⇒ Object private
-
#initialize(operation) ⇒ Callable
constructor
private
A new instance of Callable.
Constructor Details
#initialize(operation) ⇒ Callable
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.
Returns a new instance of Callable.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dry/transaction/callable.rb', line 18 def initialize(operation) @operation = case operation when Proc, Method operation else operation.method(:call) end @arity = @operation.arity end |
Instance Attribute Details
#arity ⇒ Object (readonly)
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.
16 17 18 |
# File 'lib/dry/transaction/callable.rb', line 16 def arity @arity end |
#operation ⇒ Object (readonly)
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.
15 16 17 |
# File 'lib/dry/transaction/callable.rb', line 15 def operation @operation end |
Class Method Details
.[](callable) ⇒ 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.
5 6 7 8 9 10 11 12 13 |
# File 'lib/dry/transaction/callable.rb', line 5 def self.[](callable) if callable.is_a?(self) callable elsif callable.nil? nil else new(callable) end end |
Instance Method Details
#call(*args, &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.
29 30 31 32 33 34 35 |
# File 'lib/dry/transaction/callable.rb', line 29 def call(*args, &block) if arity.zero? operation.(&block) else operation.(*args, &block) end end |