Module: Undercarriage::Controllers::ActionConcern
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/undercarriage/controllers/action_concern.rb
Overview
Action helpers
Helpers for the controller or view to help identify the action
Usage
class ExamplesController < ApplicationController
include Undercarriage::Controllers::ActionConcern
end
Instance Method Summary collapse
-
#action?(action_method) ⇒ Boolean
Check action.
-
#collection_action? ⇒ Boolean
Check if collection.
-
#create_action? ⇒ Boolean
Check if create.
-
#create_actions? ⇒ Boolean
(also: #new_actions?)
Check if create or new.
-
#destroy_action? ⇒ Boolean
Check if destroy.
-
#edit_action? ⇒ Boolean
Check if edit.
-
#index_action? ⇒ Boolean
Check if index.
-
#member_action? ⇒ Boolean
Check if member.
-
#new_action? ⇒ Boolean
Check if new.
-
#show_action? ⇒ Boolean
Check if show.
-
#update_action? ⇒ Boolean
Check if update.
-
#update_actions? ⇒ Boolean
(also: #edit_actions?)
Check if edit or update.
Instance Method Details
#action?(action_method) ⇒ Boolean
Check action
Check if action is a certain action type
Usage
action?(:show) # true
action?('show') # true
action?(:index) # false
49 50 51 |
# File 'lib/undercarriage/controllers/action_concern.rb', line 49 def action?(action_method) action == action_method.to_sym end |
#collection_action? ⇒ Boolean
Check if collection
Check if action is a collection action type. An action is a collection type if it is the index action
Usage
collection_action? # true
collection_action? # false
169 170 171 |
# File 'lib/undercarriage/controllers/action_concern.rb', line 169 def collection_action? collection_actions.include?(action) end |
#create_action? ⇒ Boolean
Check if create
Check if action is the create action type. The check will pass if it is a create action
Usage
create_action? # true
create_action? # false
109 110 111 |
# File 'lib/undercarriage/controllers/action_concern.rb', line 109 def create_action? action?('create') end |
#create_actions? ⇒ Boolean Also known as: new_actions?
Check if create or new
Check if action is a create or new action type. The check will pass if it is a create or new action
Usage
create_actions? # true
create_actions? # false
new_actions? # true
new_actions? # false
187 188 189 |
# File 'lib/undercarriage/controllers/action_concern.rb', line 187 def create_actions? create_actions.include?(action) end |
#destroy_action? ⇒ Boolean
Check if destroy
Check if action is the destroy action type. The check will pass if it is a destroy action
Usage
destroy_action? # true
destroy_action? # false
154 155 156 |
# File 'lib/undercarriage/controllers/action_concern.rb', line 154 def destroy_action? action?('destroy') end |
#edit_action? ⇒ Boolean
Check if edit
Check if action is the edit action type. The check will pass if it is an edit action
Usage
edit_action? # true
edit_action? # false
124 125 126 |
# File 'lib/undercarriage/controllers/action_concern.rb', line 124 def edit_action? action?('edit') end |
#index_action? ⇒ Boolean
Check if index
Check if action is the index action type. The check will pass if it is an index action
Usage
index_action? # true
index_action? # false
64 65 66 |
# File 'lib/undercarriage/controllers/action_concern.rb', line 64 def index_action? action?('index') end |
#member_action? ⇒ Boolean
Check if member
Check if action is a member action type. An action is a member type if it is the edit, show, or update action
Usage
member_action? # true
member_action? # false
204 205 206 |
# File 'lib/undercarriage/controllers/action_concern.rb', line 204 def member_action? member_actions.include?(action) end |
#new_action? ⇒ Boolean
Check if new
Check if action is the new action type. The check will pass if it is a new action
Usage
new_action? # true
new_action? # false
94 95 96 |
# File 'lib/undercarriage/controllers/action_concern.rb', line 94 def new_action? action?('new') end |
#show_action? ⇒ Boolean
Check if show
Check if action is the show action type. The check will pass if it is a show action
Usage
show_action? # true
show_action? # false
79 80 81 |
# File 'lib/undercarriage/controllers/action_concern.rb', line 79 def show_action? action?('show') end |
#update_action? ⇒ Boolean
Check if update
Check if action is the update action type. The check will pass if it is an update action
Usage
update_action? # true
update_action? # false
139 140 141 |
# File 'lib/undercarriage/controllers/action_concern.rb', line 139 def update_action? action?('update') end |
#update_actions? ⇒ Boolean Also known as: edit_actions?
Check if edit or update
Check if action is an edit or update action type. The check will pass if it is an edit or update action
Usage
update_actions? # true
update_actions? # false
edit_actions? # true
edit_actions? # false
222 223 224 |
# File 'lib/undercarriage/controllers/action_concern.rb', line 222 def update_actions? update_actions.include?(action) end |