Class: Textus::Workflow::DSL::Definition
- Inherits:
-
Object
- Object
- Textus::Workflow::DSL::Definition
- Defined in:
- lib/textus/workflow/dsl.rb
Instance Attribute Summary collapse
-
#match_pattern ⇒ Object
readonly
Returns the value of attribute match_pattern.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#publish_block ⇒ Object
readonly
Returns the value of attribute publish_block.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
-
#initialize(name) ⇒ Definition
constructor
A new instance of Definition.
- #match(pattern) ⇒ Object
- #match?(key) ⇒ Boolean
- #publish(&block) ⇒ Object
- #step(name, callable_or_opt = nil, timeout: nil, &block) ⇒ Object
Constructor Details
#initialize(name) ⇒ Definition
Returns a new instance of Definition.
9 10 11 12 13 14 |
# File 'lib/textus/workflow/dsl.rb', line 9 def initialize(name) @name = name @steps = [] @match_pattern = nil @publish_block = nil end |
Instance Attribute Details
#match_pattern ⇒ Object (readonly)
Returns the value of attribute match_pattern.
7 8 9 |
# File 'lib/textus/workflow/dsl.rb', line 7 def match_pattern @match_pattern end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/textus/workflow/dsl.rb', line 7 def name @name end |
#publish_block ⇒ Object (readonly)
Returns the value of attribute publish_block.
7 8 9 |
# File 'lib/textus/workflow/dsl.rb', line 7 def publish_block @publish_block end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
7 8 9 |
# File 'lib/textus/workflow/dsl.rb', line 7 def steps @steps end |
Instance Method Details
#match(pattern) ⇒ Object
16 17 18 |
# File 'lib/textus/workflow/dsl.rb', line 16 def match(pattern) @match_pattern = pattern end |
#match?(key) ⇒ Boolean
36 37 38 39 40 |
# File 'lib/textus/workflow/dsl.rb', line 36 def match?(key) return false unless @match_pattern Pattern.match?(@match_pattern, key) end |
#publish(&block) ⇒ Object
32 33 34 |
# File 'lib/textus/workflow/dsl.rb', line 32 def publish(&block) @publish_block = block || :default end |
#step(name, callable_or_opt = nil, timeout: nil, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/textus/workflow/dsl.rb', line 20 def step(name, callable_or_opt = nil, timeout: nil, &block) callable = if callable_or_opt.respond_to?(:call) callable_or_opt elsif block block else raise ArgumentError.new("step :#{name} requires a block or a callable (got neither)") end t = callable_or_opt.is_a?(Hash) ? callable_or_opt[:timeout] : timeout @steps << Step.new(name: name, callable: callable, timeout: t) end |