Module: Mithril::Controllers::Mixins::ActionsBase::ClassMethods
- Defined in:
- lib/mithril/controllers/mixins/actions_base.rb
Overview
These methods get extended into the class of the controller through the magic of Mixin.
Instance Method Summary collapse
-
#actions(allow_private = false) ⇒ Hash
Lists the actions defined for the current controller by its base class.
-
#define_action(key, params = {}) {|session, arguments| ... } ⇒ Object
Defines an action to which the controller will respond.
Instance Method Details
#actions(allow_private = false) ⇒ Hash
Lists the actions defined for the current controller by its base class. In almost all cases, the actions instance method should be used instead, as it handles class-based inheritance.
54 55 56 57 58 59 60 61 62 |
# File 'lib/mithril/controllers/mixins/actions_base.rb', line 54 def actions(allow_private = false) actions = @actions ||= {} unless allow_private actions = actions.select { |key, action| !action.has_key? :private } end # unless actions end |
#define_action(key, params = {}) {|session, arguments| ... } ⇒ Object
Defines an action to which the controller will respond.
37 38 39 40 41 42 43 44 |
# File 'lib/mithril/controllers/mixins/actions_base.rb', line 37 def define_action(key, params = {}, &block) key = key.to_s.downcase.gsub(/\s+|\-+/,'_').intern define_method :"action_#{key}", &block @actions ||= {} @actions[key] = params end |