Module: Trailblazer::V1_1::Operation::Callback
- Defined in:
- lib/trailblazer/1.1/operation/callback.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#callback!(name = :default, options = { operation: self, contract: contract, params: @params }) ⇒ Object
FIXME: test options.
- #dispatch!(*args, &block) ⇒ Object
- #invocations ⇒ Object
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/trailblazer/1.1/operation/callback.rb', line 5 def self.included(base) base.extend ClassMethods base.extend Declarative::Heritage::Inherited base.extend Declarative::Heritage::DSL end |
Instance Method Details
#callback!(name = :default, options = { operation: self, contract: contract, params: @params }) ⇒ Object
FIXME: test options.
12 13 14 15 16 17 18 19 20 |
# File 'lib/trailblazer/1.1/operation/callback.rb', line 12 def callback!(name=:default, ={ operation: self, contract: contract, params: @params }) # FIXME: test options. config = self.class.callbacks.fetch(name) # TODO: test exception group = config[:group].new(contract) [:context] ||= (config[:context] == :operation ? self : group) group.() invocations[name] = group end |
#dispatch!(*args, &block) ⇒ Object
22 23 24 |
# File 'lib/trailblazer/1.1/operation/callback.rb', line 22 def dispatch!(*args, &block) callback!(*args, &block) end |
#invocations ⇒ Object
26 27 28 |
# File 'lib/trailblazer/1.1/operation/callback.rb', line 26 def invocations @invocations ||= {} end |