Module: Trax::Core::Mixin

Defined in:
lib/trax/core/mixin.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/trax/core/mixin.rb', line 12

def self.extended(base)
  base.extend(::ActiveSupport::Concern)

  super(base)

  trace = ::TracePoint.new(:end) do |tracepoint|
    if tracepoint.self == base
      trace.disable

      if base.instance_variable_defined?(:@_after_extended_block)
        base.instance_variable_get(:@_after_extended_block).call
      end
    end
  end

  trace.enable

  mixin_namespace.register_mixin(base) unless self == ::Trax::Core::Mixin
end

Instance Method Details

#before_mixed_in(&block) ⇒ Object



8
9
10
# File 'lib/trax/core/mixin.rb', line 8

def before_mixed_in(&block)
  self.instance_variable_set(:@_before_mixed_in_block, block)
end

#on_mixed_in(&block) ⇒ Object



4
5
6
# File 'lib/trax/core/mixin.rb', line 4

def on_mixed_in(&block)
  self.instance_variable_set(:@_on_mixed_in_block, block)
end