Class: FlowCore::Definition::Trigger
- Inherits:
-
Object
- Object
- FlowCore::Definition::Trigger
- Defined in:
- lib/flow_core/definition/trigger.rb
Instance Method Summary collapse
- #compile ⇒ Object
-
#initialize(attributes) ⇒ Trigger
constructor
A new instance of Trigger.
Constructor Details
#initialize(attributes) ⇒ Trigger
Returns a new instance of Trigger.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/flow_core/definition/trigger.rb', line 5 def initialize(attributes) constant_or_klass = attributes.is_a?(Hash) ? attributes.delete(:type) : attributes @klass = if constant_or_klass.is_a? String constant_or_klass.safe_constantize else constant_or_klass end unless @klass && @klass < FlowCore::TransitionTrigger raise TypeError, "First argument expect `FlowCore::TransitionTrigger` subclass or its constant name - #{constant_or_klass}" end @configuration = attributes.is_a?(Hash) ? attributes : nil end |
Instance Method Details
#compile ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/flow_core/definition/trigger.rb', line 20 def compile if @configuration&.any? { type: @klass.to_s, configuration: @configuration } else { type: @klass.to_s } end end |