Class: LcpRuby::BatchActions::CustomActionDispatcher
- Inherits:
-
Object
- Object
- LcpRuby::BatchActions::CustomActionDispatcher
- Defined in:
- lib/lcp_ruby/batch_actions/custom_action_dispatcher.rb
Instance Attribute Summary collapse
-
#action_key ⇒ Object
readonly
Returns the value of attribute action_key.
-
#batch_operation ⇒ Object
readonly
Returns the value of attribute batch_operation.
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#model_class ⇒ Object
readonly
Returns the value of attribute model_class.
-
#model_definition ⇒ Object
readonly
Returns the value of attribute model_definition.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#progress ⇒ Object
readonly
Returns the value of attribute progress.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(action_key:, records:, current_user:, params:, model_class:, model_definition:, batch_operation: nil, &progress) ⇒ CustomActionDispatcher
constructor
A new instance of CustomActionDispatcher.
Constructor Details
#initialize(action_key:, records:, current_user:, params:, model_class:, model_definition:, batch_operation: nil, &progress) ⇒ CustomActionDispatcher
Returns a new instance of CustomActionDispatcher.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/lcp_ruby/batch_actions/custom_action_dispatcher.rb', line 7 def initialize(action_key:, records:, current_user:, params:, model_class:, model_definition:, batch_operation: nil, &progress) @action_key = action_key @records = records @current_user = current_user @params = params @model_class = model_class @model_definition = model_definition @batch_operation = batch_operation @progress = progress end |
Instance Attribute Details
#action_key ⇒ Object (readonly)
Returns the value of attribute action_key.
4 5 6 |
# File 'lib/lcp_ruby/batch_actions/custom_action_dispatcher.rb', line 4 def action_key @action_key end |
#batch_operation ⇒ Object (readonly)
Returns the value of attribute batch_operation.
4 5 6 |
# File 'lib/lcp_ruby/batch_actions/custom_action_dispatcher.rb', line 4 def batch_operation @batch_operation end |
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
4 5 6 |
# File 'lib/lcp_ruby/batch_actions/custom_action_dispatcher.rb', line 4 def current_user @current_user end |
#model_class ⇒ Object (readonly)
Returns the value of attribute model_class.
4 5 6 |
# File 'lib/lcp_ruby/batch_actions/custom_action_dispatcher.rb', line 4 def model_class @model_class end |
#model_definition ⇒ Object (readonly)
Returns the value of attribute model_definition.
4 5 6 |
# File 'lib/lcp_ruby/batch_actions/custom_action_dispatcher.rb', line 4 def model_definition @model_definition end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/lcp_ruby/batch_actions/custom_action_dispatcher.rb', line 4 def params @params end |
#progress ⇒ Object (readonly)
Returns the value of attribute progress.
4 5 6 |
# File 'lib/lcp_ruby/batch_actions/custom_action_dispatcher.rb', line 4 def progress @progress end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
4 5 6 |
# File 'lib/lcp_ruby/batch_actions/custom_action_dispatcher.rb', line 4 def records @records end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lcp_ruby/batch_actions/custom_action_dispatcher.rb', line 19 def call action_class = Actions::ActionRegistry.action_for(action_key) raise LcpRuby::Error, "Action '#{action_key}' not found" unless action_class if action_class.batch_capable? execute_bulk(action_class) else execute_per_record(action_class) end end |