Class: LcpRuby::Workflow::StateDefinition
- Inherits:
-
Object
- Object
- LcpRuby::Workflow::StateDefinition
- Defined in:
- lib/lcp_ruby/workflow/state_definition.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#description_source_loc ⇒ Object
readonly
Returns the value of attribute description_source_loc.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#on_entry ⇒ Object
readonly
Returns the value of attribute on_entry.
-
#on_exit ⇒ Object
readonly
Returns the value of attribute on_exit.
-
#readonly_fields ⇒ Object
readonly
Returns the value of attribute readonly_fields.
-
#source_loc ⇒ Object
readonly
Returns the value of attribute source_loc.
Class Method Summary collapse
Instance Method Summary collapse
- #all_readonly? ⇒ Boolean
- #initial? ⇒ Boolean
-
#initialize(attrs = {}) ⇒ StateDefinition
constructor
A new instance of StateDefinition.
- #readonly_field?(field_name) ⇒ Boolean
- #terminal? ⇒ Boolean
Constructor Details
#initialize(attrs = {}) ⇒ StateDefinition
Returns a new instance of StateDefinition.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 8 def initialize(attrs = {}) @name = attrs[:name].to_s @initial = attrs[:initial] == true @category = attrs[:category]&.to_s @color = attrs[:color]&.to_s @icon = attrs[:icon]&.to_s @all_readonly = (attrs[:readonly_fields].to_s == "all") @readonly_fields = @all_readonly ? [] : Array(attrs[:readonly_fields]).map(&:to_s) @on_entry = Array(attrs[:on_entry]).map(&:to_s) @on_exit = Array(attrs[:on_exit]).map(&:to_s) @description = attrs[:description]&.to_s # i18n_check Phase 3a — captured by WorkflowBuilder#state from # the DSL block. nil for YAML-loaded workflows (Pass 3 covers). @source_loc = attrs[:source_loc] @description_source_loc = attrs[:description_source_loc] end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
4 5 6 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 4 def category @category end |
#color ⇒ Object (readonly)
Returns the value of attribute color.
4 5 6 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 4 def color @color end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
4 5 6 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 4 def description @description end |
#description_source_loc ⇒ Object (readonly)
Returns the value of attribute description_source_loc.
4 5 6 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 4 def description_source_loc @description_source_loc end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
4 5 6 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 4 def icon @icon end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 4 def name @name end |
#on_entry ⇒ Object (readonly)
Returns the value of attribute on_entry.
4 5 6 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 4 def on_entry @on_entry end |
#on_exit ⇒ Object (readonly)
Returns the value of attribute on_exit.
4 5 6 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 4 def on_exit @on_exit end |
#readonly_fields ⇒ Object (readonly)
Returns the value of attribute readonly_fields.
4 5 6 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 4 def readonly_fields @readonly_fields end |
#source_loc ⇒ Object (readonly)
Returns the value of attribute source_loc.
4 5 6 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 4 def source_loc @source_loc end |
Class Method Details
.from_hash(name, hash) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 25 def self.from_hash(name, hash) hash = (hash || {}).transform_keys(&:to_s) new( name: name, initial: hash["initial"], category: hash["category"], color: hash["color"], icon: hash["icon"], readonly_fields: hash["readonly_fields"], on_entry: hash["on_entry"], on_exit: hash["on_exit"], description: hash["description"], source_loc: hash["_source_loc"], description_source_loc: hash["_description_source_loc"] ) end |
Instance Method Details
#all_readonly? ⇒ Boolean
50 51 52 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 50 def all_readonly? @all_readonly == true end |
#initial? ⇒ Boolean
42 43 44 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 42 def initial? @initial == true end |
#readonly_field?(field_name) ⇒ Boolean
54 55 56 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 54 def readonly_field?(field_name) @all_readonly || @readonly_fields.include?(field_name.to_s) end |
#terminal? ⇒ Boolean
46 47 48 |
# File 'lib/lcp_ruby/workflow/state_definition.rb', line 46 def terminal? @category == "terminal" end |