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



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

def self.extended(ctrl)
  ctrl.define_parent_actions
end

Instance Method Details

#define_parent_actionsObject



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

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



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

def inherited(ctrl)
  ctrl.define_parent_actions
end