Class: CemAcpt::Actions::ActionConfig
- Inherits:
-
Object
- Object
- CemAcpt::Actions::ActionConfig
- Defined in:
- lib/cem_acpt/actions.rb
Overview
Represents the configuration for the Actions module.
Instance Attribute Summary collapse
-
#except ⇒ Object
Returns the value of attribute except.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#only ⇒ Object
Returns the value of attribute only.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Returns the action group with the specified name.
-
#action_names(include_all: false) ⇒ Array<String>
Returns a list of the names of all registered actions.
-
#initialize ⇒ ActionConfig
constructor
A new instance of ActionConfig.
-
#register_group(name, **opts) ⇒ Object
Registers an action group.
Constructor Details
#initialize ⇒ ActionConfig
Returns a new instance of ActionConfig.
71 72 73 74 75 76 77 |
# File 'lib/cem_acpt/actions.rb', line 71 def initialize @groups = { main: ActionGroup.new, } @only = [] @except = [] end |
Instance Attribute Details
#except ⇒ Object
Returns the value of attribute except.
69 70 71 |
# File 'lib/cem_acpt/actions.rb', line 69 def except @except end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
69 70 71 |
# File 'lib/cem_acpt/actions.rb', line 69 def groups @groups end |
#only ⇒ Object
Returns the value of attribute only.
69 70 71 |
# File 'lib/cem_acpt/actions.rb', line 69 def only @only end |
Instance Method Details
#[](key) ⇒ Object
Returns the action group with the specified name.
81 82 83 |
# File 'lib/cem_acpt/actions.rb', line 81 def [](key) groups[key.to_sym] end |
#action_names(include_all: false) ⇒ Array<String>
Returns a list of the names of all registered actions.
101 102 103 104 105 |
# File 'lib/cem_acpt/actions.rb', line 101 def action_names(include_all: false) return groups.values.map { |a| a.actions }.flatten.map(&:name).uniq if include_all groups.values.map { |a| a.filter_actions }.flatten.map(&:name).uniq end |
#register_group(name, **opts) ⇒ Object
Registers an action group. Actions groups are logical groups of actions that can be executed in parallel.
92 93 94 95 96 97 |
# File 'lib/cem_acpt/actions.rb', line 92 def register_group(name, **opts) return groups[name] if groups.key?(name) groups[name] = ActionGroup.new(name, **opts) groups[name] end |