Class: Avo::Resources::Controls::Action

Inherits:
BaseControl show all
Defined in:
lib/avo/resources/controls/action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseControl

#action?, #actions_list?, #back_button?, #color, #delete_button?, #detach_button?, #edit_button?, #icon, #link_to?, #style, #title

Constructor Details

#initialize(klass, model: nil, resource: nil, view: nil, **args) ⇒ Action

Returns a new instance of Action.



7
8
9
10
11
12
13
14
# File 'lib/avo/resources/controls/action.rb', line 7

def initialize(klass, model: nil, resource: nil, view: nil, **args)
  super(**args)

  @klass = klass
  @resource = resource
  @model = model
  @view = view
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



5
6
7
# File 'lib/avo/resources/controls/action.rb', line 5

def klass
  @klass
end

Instance Method Details

#actionObject



16
17
18
# File 'lib/avo/resources/controls/action.rb', line 16

def action
  @instance ||= @klass.new(model: @model, resource: @resource, view: @view)
end

#labelObject



24
25
26
# File 'lib/avo/resources/controls/action.rb', line 24

def label
  @args[:label] || action.action_name
end

#pathObject



20
21
22
# File 'lib/avo/resources/controls/action.rb', line 20

def path
  Avo::Services::URIService.parse(@resource.record_path).append_paths("actions", action.param_id).to_s
end