Module: Granite::Projector::ControllerActions::ClassMethods
- Defined in:
- lib/granite/projector/controller_actions.rb
Instance Method Summary collapse
Instance Method Details
#action(name, options = {}, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/granite/projector/controller_actions.rb', line 20 def action(name, = {}, &block) if block self.controller_actions = controller_actions.merge(name.to_sym => ) controller_class.__send__(:define_method, name, &block) class_eval <<-METHOD, __FILE__, __LINE__ + 1 def #{name}_url(options = {}) action_url(:#{name}, options) end def #{name}_path(options = {}) action_path(:#{name}, options) end METHOD else controller_actions[name.to_sym] end end |
#action_for(http_method, action) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/granite/projector/controller_actions.rb', line 38 def action_for(http_method, action) controller_actions.find do |controller_action, | .fetch(:as, controller_action).to_s == action && Array(.fetch(:method)).include?(http_method) end&.first end |