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

Examples:

Controller

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

Examples:

View

action?(:show) # true
action?("show") # true
action?(:index) # false

Parameters:

  • action_method (String, Symbol)

    the action to test

Returns:

  • (Boolean)

    if action matches



48
49
50
# File 'lib/undercarriage/controllers/action_concern.rb', line 48

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

Examples:

View

collection_action? # true
collection_action? # false

Returns:

  • (Boolean)

    if action is collection type



160
161
162
# File 'lib/undercarriage/controllers/action_concern.rb', line 160

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

Examples:

View

create_action? # true
create_action? # false

Returns:

  • (Boolean)

    if action is action type



104
105
106
# File 'lib/undercarriage/controllers/action_concern.rb', line 104

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

Examples:

View create

create_actions? # true
create_actions? # false

View new

new_actions? # true
new_actions? # false

Returns:

  • (Boolean)

    if action is actions type



177
178
179
# File 'lib/undercarriage/controllers/action_concern.rb', line 177

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

Examples:

View

destroy_action? # true
destroy_action? # false

Returns:

  • (Boolean)

    if action is action type



146
147
148
# File 'lib/undercarriage/controllers/action_concern.rb', line 146

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

Examples:

View

edit_action? # true
edit_action? # false

Returns:

  • (Boolean)

    if action is action type



118
119
120
# File 'lib/undercarriage/controllers/action_concern.rb', line 118

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

Examples:

View

index_action? # true
index_action? # false

Returns:

  • (Boolean)

    if action is action type



62
63
64
# File 'lib/undercarriage/controllers/action_concern.rb', line 62

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

Examples:

View

member_action? # true
member_action? # false

Returns:

  • (Boolean)

    if action is member type



193
194
195
# File 'lib/undercarriage/controllers/action_concern.rb', line 193

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

Examples:

View

new_action? # true
new_action? # false

Returns:

  • (Boolean)

    if action is action type



90
91
92
# File 'lib/undercarriage/controllers/action_concern.rb', line 90

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

Examples:

View

show_action? # true
show_action? # false

Returns:

  • (Boolean)

    if action is action type



76
77
78
# File 'lib/undercarriage/controllers/action_concern.rb', line 76

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

Examples:

View

update_action? # true
update_action? # false

Returns:

  • (Boolean)

    if action is action type



132
133
134
# File 'lib/undercarriage/controllers/action_concern.rb', line 132

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

Examples:

View update

update_actions? # true
update_actions? # false

View edit

edit_actions? # true
edit_actions? # false

Returns:

  • (Boolean)

    if action is actions type



210
211
212
# File 'lib/undercarriage/controllers/action_concern.rb', line 210

def update_actions?
  update_actions.include?(action)
end