Class: Plutonium::Action::Base
- Inherits:
-
Object
- Object
- Plutonium::Action::Base
- Defined in:
- lib/plutonium/action/base.rb
Overview
Base class for all actions in the Plutonium framework.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#category ⇒ Symbol?
readonly
The category of the action.
-
#color ⇒ Symbol?
readonly
The color associated with the action.
-
#confirmation ⇒ String?
readonly
The confirmation message for the action.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#icon ⇒ String?
readonly
The icon associated with the action.
-
#label ⇒ String
readonly
The human-readable label for the action.
-
#name ⇒ Symbol
readonly
The name of the action.
-
#position ⇒ Integer
readonly
The position of the action within its category.
-
#return_to ⇒ Object
readonly
Returns the value of attribute return_to.
-
#route_options ⇒ RouteOptions
readonly
The routing options for the action.
-
#turbo ⇒ Object
readonly
Returns the value of attribute turbo.
-
#turbo_frame ⇒ String?
readonly
The Turbo Frame ID for the action.
Instance Method Summary collapse
-
#bulk_action? ⇒ Boolean
Whether this is a bulk action.
-
#collection_record_action? ⇒ Boolean
Whether this is a collection record action.
-
#initialize(name, **options) ⇒ Base
constructor
Initialize a new action.
- #permitted_by?(policy) ⇒ Boolean
-
#record_action? ⇒ Boolean
Whether this is a record action.
-
#resource_action? ⇒ Boolean
Whether this is a resource action.
Constructor Details
#initialize(name, **options) ⇒ Base
Initialize a new action.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/plutonium/action/base.rb', line 43 def initialize(name, **) @name = name.to_sym @label = [:label] || @name.to_s.titleize @description = [:description] @icon = [:icon] || Phlex::TablerIcons::ChevronRight @color = [:color] @confirmation = [:confirmation] = ([:route_options]) @turbo = [:turbo] @turbo_frame = [:turbo_frame] @return_to = [:return_to] @bulk_action = [:bulk_action] || false @collection_record_action = [:collection_record_action] || false @record_action = [:record_action] || false @resource_action = [:resource_action] || false @category = ActiveSupport::StringInquirer.new(([:category] || :secondary).to_s) @position = [:position] || 50 freeze end |
Instance Attribute Details
#category ⇒ Symbol? (readonly)
The category of the action.
18 19 20 |
# File 'lib/plutonium/action/base.rb', line 18 def category @category end |
#color ⇒ Symbol? (readonly)
The color associated with the action.
18 19 20 |
# File 'lib/plutonium/action/base.rb', line 18 def color @color end |
#confirmation ⇒ String? (readonly)
The confirmation message for the action.
18 19 20 |
# File 'lib/plutonium/action/base.rb', line 18 def confirmation @confirmation end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
19 20 21 |
# File 'lib/plutonium/action/base.rb', line 19 def description @description end |
#icon ⇒ String? (readonly)
The icon associated with the action.
18 19 20 |
# File 'lib/plutonium/action/base.rb', line 18 def icon @icon end |
#label ⇒ String (readonly)
The human-readable label for the action.
18 19 20 |
# File 'lib/plutonium/action/base.rb', line 18 def label @label end |
#name ⇒ Symbol (readonly)
The name of the action.
18 19 20 |
# File 'lib/plutonium/action/base.rb', line 18 def name @name end |
#position ⇒ Integer (readonly)
The position of the action within its category.
18 19 20 |
# File 'lib/plutonium/action/base.rb', line 18 def position @position end |
#return_to ⇒ Object (readonly)
Returns the value of attribute return_to.
19 20 21 |
# File 'lib/plutonium/action/base.rb', line 19 def return_to @return_to end |
#route_options ⇒ RouteOptions (readonly)
The routing options for the action.
18 19 20 |
# File 'lib/plutonium/action/base.rb', line 18 def end |
#turbo ⇒ Object (readonly)
Returns the value of attribute turbo.
19 20 21 |
# File 'lib/plutonium/action/base.rb', line 19 def turbo @turbo end |
#turbo_frame ⇒ String? (readonly)
The Turbo Frame ID for the action.
18 19 20 |
# File 'lib/plutonium/action/base.rb', line 18 def turbo_frame @turbo_frame end |
Instance Method Details
#bulk_action? ⇒ Boolean
Returns Whether this is a bulk action.
65 66 67 |
# File 'lib/plutonium/action/base.rb', line 65 def bulk_action? @bulk_action end |
#collection_record_action? ⇒ Boolean
Returns Whether this is a collection record action.
70 71 72 |
# File 'lib/plutonium/action/base.rb', line 70 def collection_record_action? @collection_record_action end |
#permitted_by?(policy) ⇒ Boolean
84 85 86 |
# File 'lib/plutonium/action/base.rb', line 84 def permitted_by?(policy) policy.allowed_to?(:"#{name}?") end |
#record_action? ⇒ Boolean
Returns Whether this is a record action.
75 76 77 |
# File 'lib/plutonium/action/base.rb', line 75 def record_action? @record_action end |
#resource_action? ⇒ Boolean
Returns Whether this is a resource action.
80 81 82 |
# File 'lib/plutonium/action/base.rb', line 80 def resource_action? @resource_action end |