Class: Puffer::Controller::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/puffer/controller/actions.rb

Direct Known Subclasses

CollectionAction, MemberAction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, *route) ⇒ Action

Returns a new instance of Action.



27
28
29
30
31
32
# File 'lib/puffer/controller/actions.rb', line 27

def initialize controller, *route
  @controller, @route = controller, route
  options = route.extract_options!
  @display = options.key?(:display) ? options.delete(:display) : true
  route.push options
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



25
26
27
# File 'lib/puffer/controller/actions.rb', line 25

def controller
  @controller
end

#routeObject

Returns the value of attribute route.



25
26
27
# File 'lib/puffer/controller/actions.rb', line 25

def route
  @route
end

Instance Method Details

#actionObject



38
39
40
# File 'lib/puffer/controller/actions.rb', line 38

def action
  @action ||= route.second.to_sym
end

#action_scopeObject



50
51
52
# File 'lib/puffer/controller/actions.rb', line 50

def action_scope
  :actions
end

#display?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/puffer/controller/actions.rb', line 54

def display?
  @display
end

#i18n_scopeObject



46
47
48
# File 'lib/puffer/controller/actions.rb', line 46

def i18n_scope
  [:puffer, controller.controller_path.gsub(/\//, '.'), action_scope]
end

#labelObject



42
43
44
# File 'lib/puffer/controller/actions.rb', line 42

def label
  I18n.t(action, :scope => i18n_scope, :default => action.to_s.humanize)
end

#methodObject



34
35
36
# File 'lib/puffer/controller/actions.rb', line 34

def method
  @method ||= route.first.to_sym
end