Sha256: 908f440236760bc3dfcfb35a2cf68cef70ff883a003c715bf10e42d5bbbdc986

Contents?: true

Size: 941 Bytes

Versions: 15

Compression:

Stored size: 941 Bytes

Contents

module Trax
  module Core
    module Mixin
      def on_mixed_in(&block)
        self.instance_variable_set(:@_on_mixed_in_block, block)
      end

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

      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

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
trax_core-0.0.86 lib/trax/core/mixin.rb
trax_core-0.0.85 lib/trax/core/mixin.rb
trax_core-0.0.84 lib/trax/core/mixin.rb
trax_core-0.0.83 lib/trax/core/mixin.rb
trax_core-0.0.82 lib/trax/core/mixin.rb
trax_core-0.0.81 lib/trax/core/mixin.rb
trax_core-0.0.80 lib/trax/core/mixin.rb
trax_core-0.0.79 lib/trax/core/mixin.rb
trax_core-0.0.78 lib/trax/core/mixin.rb
trax_core-0.0.77 lib/trax/core/mixin.rb
trax_core-0.0.76 lib/trax/core/mixin.rb
trax_core-0.0.74 lib/trax/core/mixin.rb
trax_core-0.0.73 lib/trax/core/mixin.rb
trax_core-0.0.72 lib/trax/core/mixin.rb
trax_core-0.0.71 lib/trax/core/mixin.rb