Class: Olivander::Resources::ResourceAction
- Inherits:
-
Object
- Object
- Olivander::Resources::ResourceAction
- Defined in:
- app/controllers/concerns/olivander/resources/route_builder.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#confirm ⇒ Object
Returns the value of attribute confirm.
-
#confirm_with ⇒ Object
Returns the value of attribute confirm_with.
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#crud_action ⇒ Object
Returns the value of attribute crud_action.
-
#no_route ⇒ Object
Returns the value of attribute no_route.
-
#path_helper ⇒ Object
Returns the value of attribute path_helper.
-
#primary ⇒ Object
Returns the value of attribute primary.
-
#show_in_datatable ⇒ Object
Returns the value of attribute show_in_datatable.
-
#show_in_form ⇒ Object
Returns the value of attribute show_in_form.
-
#sym ⇒ Object
Returns the value of attribute sym.
-
#turbo_frame ⇒ Object
Returns the value of attribute turbo_frame.
-
#verb ⇒ Object
Returns the value of attribute verb.
Instance Method Summary collapse
- #args_hash(options = nil) ⇒ Object
- #confirm_key ⇒ Object
- #confirmation_message ⇒ Object
- #data_hash ⇒ Object
-
#initialize(sym, action: nil, controller: nil, verb: :get, confirm: false, turbo_frame: nil, collection: false, crud_action: false, show_in_form: true, show_in_datatable: true, no_route: false, path_helper: nil, confirm_with: nil, primary: nil) ⇒ ResourceAction
constructor
A new instance of ResourceAction.
Constructor Details
#initialize(sym, action: nil, controller: nil, verb: :get, confirm: false, turbo_frame: nil, collection: false, crud_action: false, show_in_form: true, show_in_datatable: true, no_route: false, path_helper: nil, confirm_with: nil, primary: nil) ⇒ ResourceAction
Returns a new instance of ResourceAction.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 8 def initialize(sym, action: nil, controller: nil, verb: :get, confirm: false, turbo_frame: nil, collection: false, crud_action: false, show_in_form: true, show_in_datatable: true, no_route: false, path_helper: nil, confirm_with: nil, primary: nil) self.sym = sym self.action = action || sym self.controller = controller self.verb = verb self.confirm = confirm self.turbo_frame = turbo_frame self.collection = collection self.crud_action = crud_action self.show_in_form = show_in_form self.show_in_datatable = show_in_datatable self.no_route = no_route self.path_helper = path_helper self.confirm_with = confirm_with self.primary = primary || crud_action end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
4 5 6 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 4 def action @action end |
#collection ⇒ Object
Returns the value of attribute collection.
4 5 6 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 4 def collection @collection end |
#confirm ⇒ Object
Returns the value of attribute confirm.
4 5 6 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 4 def confirm @confirm end |
#confirm_with ⇒ Object
Returns the value of attribute confirm_with.
4 5 6 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 4 def confirm_with @confirm_with end |
#controller ⇒ Object
Returns the value of attribute controller.
4 5 6 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 4 def controller @controller end |
#crud_action ⇒ Object
Returns the value of attribute crud_action.
4 5 6 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 4 def crud_action @crud_action end |
#no_route ⇒ Object
Returns the value of attribute no_route.
4 5 6 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 4 def no_route @no_route end |
#path_helper ⇒ Object
Returns the value of attribute path_helper.
4 5 6 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 4 def path_helper @path_helper end |
#primary ⇒ Object
Returns the value of attribute primary.
4 5 6 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 4 def primary @primary end |
#show_in_datatable ⇒ Object
Returns the value of attribute show_in_datatable.
4 5 6 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 4 def show_in_datatable @show_in_datatable end |
#show_in_form ⇒ Object
Returns the value of attribute show_in_form.
4 5 6 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 4 def show_in_form @show_in_form end |
#sym ⇒ Object
Returns the value of attribute sym.
4 5 6 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 4 def sym @sym end |
#turbo_frame ⇒ Object
Returns the value of attribute turbo_frame.
4 5 6 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 4 def turbo_frame @turbo_frame end |
#verb ⇒ Object
Returns the value of attribute verb.
4 5 6 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 4 def verb @verb end |
Instance Method Details
#args_hash(options = nil) ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 28 def args_hash( = nil) {}.tap do |h| h.merge!(method: verb) if turbo_frame.blank? h.merge!(data: data_hash) h.merge!() if .present? end end |
#confirm_key ⇒ Object
45 46 47 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 45 def confirm_key turbo_frame.present? ? :turbo_confirm : :confirm end |
#confirmation_message ⇒ Object
49 50 51 52 53 54 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 49 def return confirm_with if confirm_with.present? return I18n.t('activerecord.actions.delete-confirmation') if verb == :delete nil end |
#data_hash ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'app/controllers/concerns/olivander/resources/route_builder.rb', line 36 def data_hash {}.tap do |h| h.merge!(turbo: true, turbo_method: verb, turbo_frame: turbo_frame) if turbo_frame.present? = h.merge!(confirm_key => ) unless .blank? end end |