Module: SuperCallbacks
- Defined in:
- lib/super_callbacks/prepended.rb,
lib/super_callbacks.rb,
lib/super_callbacks/helpers.rb,
lib/super_callbacks/version.rb,
lib/super_callbacks/class_methods.rb,
lib/super_callbacks/instance_methods.rb,
lib/super_callbacks/class_and_instance_methods.rb
Overview
This is the module that will be prepended to the base (target) class where ‘include SuperCallbacks` have been called. This will be always a new instance of a Module, and will not be a permanent Module. This is important because, this module-instance is used by SuperCallbacks to define the methods whenever `before` or `after` is called. These defined methods here will then have a `super` inside it, which then will also call the “real” method defined in the target class.
Defined Under Namespace
Modules: ClassAndInstanceMethods, ClassMethods, Helpers, InheritancePrepender, InstanceMethods Classes: Prepended
Constant Summary collapse
- VALID_OPTION_KEYS =
[:if].freeze
- VERSION =
'1.3.1'
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/super_callbacks.rb', line 11 def self.included(base) # prevent re-including return if base.ancestors.detect { |ancestor| ancestor.is_a? SuperCallbacks::Prepended } (base) base.singleton_class.send :attr_accessor, *[:before_callbacks, :after_callbacks] base.send :attr_accessor, *[:before_callbacks, :after_callbacks] base.extend ClassMethods base.send :include, InstanceMethods base.extend ClassAndInstanceMethods base.send :include, ClassAndInstanceMethods base.singleton_class.send :attr_accessor, :super_callbacks_prepended base.super_callbacks_prepended = Prepended.new(base) base.send :prepend, base.super_callbacks_prepended # needed to fix bug while still support nested callbacks of which methods # are defined in the subclasses base.singleton_class.send :prepend, InheritancePrepender end |