Class: Avo::Resources::Controls::Action
- Inherits:
-
BaseControl
- Object
- BaseControl
- Avo::Resources::Controls::Action
- Defined in:
- lib/avo/resources/controls/action.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #action ⇒ Object
-
#initialize(klass, model: nil, resource: nil, view: nil, **args) ⇒ Action
constructor
A new instance of Action.
- #label ⇒ Object
- #path ⇒ Object
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
#klass ⇒ Object (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
#action ⇒ Object
16 17 18 19 20 |
# File 'lib/avo/resources/controls/action.rb', line 16 def action return @instance if @instance.present? @instance = @klass.new(model: @model, resource: @resource, view: @view) end |
#label ⇒ Object
26 27 28 |
# File 'lib/avo/resources/controls/action.rb', line 26 def label @args[:label] || action.action_name end |
#path ⇒ Object
22 23 24 |
# File 'lib/avo/resources/controls/action.rb', line 22 def path Avo::Services::URIService.parse(@resource.record_path).append_paths("actions", action.param_id).to_s end |