Module: Flame::Controller::Actions
Overview
Module for work with actions
Instance Method Summary collapse
-
#actions ⇒ Array<Symbol>
Shortcut for not-inherited public methods: actions.
-
#inherit_actions(actions = nil, exclude: [], from: superclass) ⇒ Object
Re-define public instance methods (actions) from parent.
-
#with_actions(mod, exclude: [], only: nil) ⇒ Object
Re-define public instance method from module.
Instance Method Details
#actions ⇒ Array<Symbol>
Shortcut for not-inherited public methods: actions
15 16 17 |
# File 'lib/flame/controller/actions.rb', line 15 def actions public_instance_methods(false) end |
#inherit_actions(actions = nil, exclude: [], from: superclass) ⇒ Object
Re-define public instance methods (actions) from parent
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/flame/controller/actions.rb', line 40 def inherit_actions(actions = nil, exclude: [], from: superclass) actions = from.actions if actions.nil? actions -= exclude actions.each do |action| define_method action, from.public_instance_method(action) end return unless from.respond_to?(:refined_http_methods) refined_http_methods.merge!( from.refined_http_methods.slice(*actions) ) end |
#with_actions(mod, exclude: [], only: nil) ⇒ Object
Re-define public instance method from module
79 80 81 82 83 84 85 86 |
# File 'lib/flame/controller/actions.rb', line 79 def with_actions(mod, exclude: [], only: nil) Module.new do @mod = mod @actions = only || (@mod.public_instance_methods(false) - exclude) extend ModuleWithActions end end |