Class: LcpRuby::Actions::BaseAction
- Inherits:
-
Object
- Object
- LcpRuby::Actions::BaseAction
- Defined in:
- lib/lcp_ruby/actions/base_action.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#model_class ⇒ Object
readonly
Returns the value of attribute model_class.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Class Method Summary collapse
-
.authorized?(_record, _user) ⇒ Boolean
Override for extra authorization beyond permission YAML.
-
.batch_capable? ⇒ Boolean
Override in subclass to indicate the action handles batch iteration internally.
-
.param_schema ⇒ Object
Override to define a form shown before execution (modal).
-
.visible?(_record, _user) ⇒ Boolean
Override for visibility conditions beyond what YAML visible_when provides.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(context = {}) ⇒ BaseAction
constructor
A new instance of BaseAction.
Constructor Details
#initialize(context = {}) ⇒ BaseAction
Returns a new instance of BaseAction.
6 7 8 9 10 11 12 |
# File 'lib/lcp_ruby/actions/base_action.rb', line 6 def initialize(context = {}) @record = context[:record] @records = context[:records] @current_user = context[:current_user] @params = context[:params] || {} @model_class = context[:model_class] end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
4 5 6 |
# File 'lib/lcp_ruby/actions/base_action.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/actions/base_action.rb', line 4 def model_class @model_class end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/lcp_ruby/actions/base_action.rb', line 4 def params @params end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
4 5 6 |
# File 'lib/lcp_ruby/actions/base_action.rb', line 4 def record @record end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
4 5 6 |
# File 'lib/lcp_ruby/actions/base_action.rb', line 4 def records @records end |
Class Method Details
.authorized?(_record, _user) ⇒ Boolean
Override for extra authorization beyond permission YAML
29 30 31 |
# File 'lib/lcp_ruby/actions/base_action.rb', line 29 def self.(_record, _user) true end |
.batch_capable? ⇒ Boolean
Override in subclass to indicate the action handles batch iteration internally. When true, the action receives the full records array in a single call. When false (default), the platform iterates per-record automatically.
36 37 38 |
# File 'lib/lcp_ruby/actions/base_action.rb', line 36 def self.batch_capable? false end |
.param_schema ⇒ Object
Override to define a form shown before execution (modal)
19 20 21 |
# File 'lib/lcp_ruby/actions/base_action.rb', line 19 def self.param_schema nil end |
.visible?(_record, _user) ⇒ Boolean
Override for visibility conditions beyond what YAML visible_when provides
24 25 26 |
# File 'lib/lcp_ruby/actions/base_action.rb', line 24 def self.visible?(_record, _user) true end |
Instance Method Details
#call ⇒ Object
14 15 16 |
# File 'lib/lcp_ruby/actions/base_action.rb', line 14 def call raise NotImplementedError, "#{self.class}#call must be implemented" end |