Class: LcpRuby::Actions::BaseAction

Inherits:
Object
  • Object
show all
Defined in:
lib/lcp_ruby/actions/base_action.rb

Direct Known Subclasses

ApiTokens::Revoke

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_userObject (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_classObject (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

#paramsObject (readonly)

Returns the value of attribute params.



4
5
6
# File 'lib/lcp_ruby/actions/base_action.rb', line 4

def params
  @params
end

#recordObject (readonly)

Returns the value of attribute record.



4
5
6
# File 'lib/lcp_ruby/actions/base_action.rb', line 4

def record
  @record
end

#recordsObject (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

Returns:

  • (Boolean)


29
30
31
# File 'lib/lcp_ruby/actions/base_action.rb', line 29

def self.authorized?(_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.

Returns:

  • (Boolean)


36
37
38
# File 'lib/lcp_ruby/actions/base_action.rb', line 36

def self.batch_capable?
  false
end

.param_schemaObject

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

Returns:

  • (Boolean)


24
25
26
# File 'lib/lcp_ruby/actions/base_action.rb', line 24

def self.visible?(_record, _user)
  true
end

Instance Method Details

#callObject

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/lcp_ruby/actions/base_action.rb', line 14

def call
  raise NotImplementedError, "#{self.class}#call must be implemented"
end