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

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

Parameters:

  • action_method (String, Symbol)

    the action to test

Returns:

  • (Boolean)

    if action matches



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

Returns:

  • (Boolean)

    if action is collection type



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

Returns:

  • (Boolean)

    if action is action type



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

Returns:

  • (Boolean)

    if action is actions type



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

Returns:

  • (Boolean)

    if action is action type



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

Returns:

  • (Boolean)

    if action is action type



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

Returns:

  • (Boolean)

    if action is action type



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

Returns:

  • (Boolean)

    if action is member type



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

Returns:

  • (Boolean)

    if action is action type



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

Returns:

  • (Boolean)

    if action is action type



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

Returns:

  • (Boolean)

    if action is action type



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

Returns:

  • (Boolean)

    if action is actions type



222
223
224
# File 'lib/undercarriage/controllers/action_concern.rb', line 222

def update_actions?
  update_actions.include?(action)
end