Sha256: 981661c6f1d3cf31e8010f83f7cf4dd008441cfa668d7f51887309cc5e032788

Contents?: true

Size: 1.21 KB

Versions: 14

Compression:

Stored size: 1.21 KB

Contents

module Trax
  module Core
    module Concern
      def self.extended(base)
        base.extend(::ActiveSupport::Concern)

        trace = ::TracePoint.new(:end) do |tracepoint|
          if tracepoint.self.singleton_class.included_modules.first == base
            if base.instance_variable_defined?(:@_after_extended_block)
              tracepoint.self.module_exec(base, &base.instance_variable_get(:@_after_extended_block))
            end

            trace.disable
          end
        end

        trace.enable

        base
      end

      def included(base = nil, &block)
        super(base, &block) if defined?(super)

        trace = ::TracePoint.new(:end) do |tracepoint|
          if tracepoint.self == base
            if self.instance_variable_defined?(:@_after_included_block)
              base.instance_eval(&self.instance_variable_get(:@_after_included_block))
            end

            trace.disable
          end
        end

        trace.enable

        base
      end

      def after_included(&block)
        self.instance_variable_set(:@_after_included_block, block)
      end

      def after_extended(&block)
        self.instance_variable_set(:@_after_extended_block, block)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

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