Module: Archangel::ActionableConcern

Extended by:
ActiveSupport::Concern
Included in:
ApplicationController
Defined in:
app/controllers/concerns/archangel/actionable_concern.rb

Overview

Controller action concern

Instance Method Summary collapse

Instance Method Details

#actionSymbol

Controller action name as a symbol

Returns:

  • (Symbol)

    the action name



27
28
29
# File 'app/controllers/concerns/archangel/actionable_concern.rb', line 27

def action
  action_name.to_sym
end

#collection_action?Boolean

Test if action is a collection action

Actions include [:index]

Collection actions can be modified by overwriting ‘#collection_actions`

Returns:

  • (Boolean)

    if action is a collection action



39
40
41
# File 'app/controllers/concerns/archangel/actionable_concern.rb', line 39

def collection_action?
  collection_actions.include?(action)
end

#edit_action?Boolean

Test if action is an edit action

Actions include [:edit, :update]

Edit actions can be modified by overwriting ‘#edit_actions`

Returns:

  • (Boolean)

    if action is an edit action



51
52
53
# File 'app/controllers/concerns/archangel/actionable_concern.rb', line 51

def edit_action?
  edit_actions.include?(action)
end

#index_action?Boolean

Test if action is the ‘index` action

Returns:

  • (Boolean)

    if action is the index action



59
60
61
# File 'app/controllers/concerns/archangel/actionable_concern.rb', line 59

def index_action?
  action?(:index)
end

#member_action?Boolean

Test if action is a member action

Actions include [:show, :edit, :update, :destroy]

Member actions can be modified by overwriting ‘#member_actions`

Returns:

  • (Boolean)

    if action is an edit action



71
72
73
# File 'app/controllers/concerns/archangel/actionable_concern.rb', line 71

def member_action?
  member_actions.include?(action)
end

#new_action?Boolean

Test if action is a new action

Actions include [:create, :new]

New actions can be modified by overwriting ‘#new_actions`

Returns:

  • (Boolean)

    if action is an edit action



83
84
85
# File 'app/controllers/concerns/archangel/actionable_concern.rb', line 83

def new_action?
  new_actions.include?(action)
end

#restful_action?Boolean

Test if action is a RESTful action

Actions include [:index, :show, :new, :create, :edit, :update, :destroy]

RESTful actions can be modified by overwriting ‘#restful_actions`

Returns:

  • (Boolean)

    if action is an edit action



95
96
97
# File 'app/controllers/concerns/archangel/actionable_concern.rb', line 95

def restful_action?
  restful_actions.include?(action)
end

#save_action?Boolean

Test if action is a save action

Actions include [:create, :update, :destroy]

Save actions can be modified by overwriting ‘#save_actions`

Returns:

  • (Boolean)

    if action is an edit action



107
108
109
# File 'app/controllers/concerns/archangel/actionable_concern.rb', line 107

def save_action?
  save_actions.include?(action)
end

#show_action?Boolean

Test if action is a show action

Actions include [:show]

Show actions can be modified by overwriting ‘#show_actions`

Returns:

  • (Boolean)

    if action is a show action



119
120
121
# File 'app/controllers/concerns/archangel/actionable_concern.rb', line 119

def show_action?
  show_actions.include?(action)
end