Sha256: 3b78ca34dc94bb89508553e2983be059cb587076f2da771965fa607f46c6838a

Contents?: true

Size: 679 Bytes

Versions: 3

Compression:

Stored size: 679 Bytes

Contents

require 'tangle/mixin/ancestry'
require 'tangle/mixin/connectedness'

module Tangle
  module Mixin
    #
    # Mixin to initialize the dynamic mixin system
    #
    module Initialize
      private

      def initialize_mixins(mixins = nil)
        case klass = self.class.name[/[^:]+$/].to_sym
        when :Graph
          @mixins = mixins
        else
          mixins = @graph.mixins unless @graph.nil?
        end

        extend_with_mixins(klass, mixins) unless mixins.nil?
      end

      def extend_with_mixins(klass, mixins)
        mixins.each do |mixin|
          extend(mixin.const_get(klass)) if mixin.const_defined?(klass)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tangle-0.5.1 lib/tangle/mixin.rb
tangle-0.5.0 lib/tangle/mixin.rb
tangle-0.4.2 lib/tangle/mixin.rb