Sha256: f94a80a3c8b2f7366ff082ab0348460d1de39d744be416b42eeafa12500f98c6

Contents?: true

Size: 843 Bytes

Versions: 1

Compression:

Stored size: 843 Bytes

Contents

require 'configurable/class_methods'

module Configurable
  module ModuleMethods
    
    # Extends including classes with Configurable::ClassMethods
    def included(mod)
      mod.extend ClassMethods
      mod.extend ModuleMethods unless mod.kind_of?(Class)
      
      unless mod.instance_variable_defined?(:@source_file)
        caller[1] =~ Lazydoc::CALLER_REGEXP
        mod.instance_variable_set(:@source_file, File.expand_path($1)) 
      end
      
      unless mod.instance_variable_defined?(:@configurations)
        mod.send(:initialize_configurations).extend(IndifferentAccess)
      end
      
      # add module configurations      
      configurations.each_pair do |key, config| 
        mod.configurations[key] = config.dup
      end unless self == Configurable
      
      super
    end
  end
  
  extend ModuleMethods
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
configurable-0.5.0 lib/configurable/module_methods.rb