Module: Flame::Controller::ParentActions

Defined in:
lib/flame/controller.rb

Overview

Module for public instance methods re-defining from superclass actions by ‘extend`

class MyController < BaseController
  FORBIDDEN_ACTIONS = %[foo bar baz].freeze
  extend Flame::Controller::ParentActions
end

Examples:

Inherit controller with parent actions without forbidden

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(ctrl) ⇒ Object



223
224
225
# File 'lib/flame/controller.rb', line 223

def self.extended(ctrl)
	ctrl.define_parent_actions
end

Instance Method Details

#define_parent_actionsObject



227
228
229
230
231
232
# File 'lib/flame/controller.rb', line 227

def define_parent_actions
	(superclass.actions - self::FORBIDDEN_ACTIONS).each do |public_method|
		um = superclass.public_instance_method(public_method)
		define_method public_method, um
	end
end

#inherited(ctrl) ⇒ Object



219
220
221
# File 'lib/flame/controller.rb', line 219

def inherited(ctrl)
	ctrl.define_parent_actions
end