Sha256: ec8b510da206ec5506c4e5deb30016a37040a8fb72c277d4fc854775e9aeb10f

Contents?: true

Size: 689 Bytes

Versions: 31

Compression:

Stored size: 689 Bytes

Contents

module ASIR
  IDENTITY_PROC = lambda { | x | x }
  module Configuration
    def self.included target
      super
      target.extend ClassMethods
    end

    # Global default config_proc
    def self.config_proc_hash
      @@config_proc_hash ||= { }
    end

    module ClassMethods
      def config_proc
        ASIR::Configuration.config_proc_hash[self]
      end
      def config_proc= x
        ASIR::Configuration.config_proc_hash[self] = x
      end
    end

    def initialize *args
      super
      ch = ASIR::Configuration.config_proc_hash
      (self.class.ancestors.map{|m| ch[m]}.compact.first ||
       ch[nil] || 
       IDENTITY_PROC
       ).call(self)
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
asir-1.2.11 lib/asir/configuration.rb
asir-1.2.10 lib/asir/configuration.rb
asir-1.2.9 lib/asir/configuration.rb
asir-1.2.8 lib/asir/configuration.rb
asir-1.2.7 lib/asir/configuration.rb
asir-1.2.6 lib/asir/configuration.rb
asir-1.2.5 lib/asir/configuration.rb
asir-1.2.3 lib/asir/configuration.rb
asir-1.2.2 lib/asir/configuration.rb
asir-1.2.1 lib/asir/configuration.rb
asir-1.2.0 lib/asir/configuration.rb
asir-1.1.12 lib/asir/configuration.rb
asir-1.1.11 lib/asir/configuration.rb
asir-1.1.10 lib/asir/configuration.rb
asir-1.1.9 lib/asir/configuration.rb
asir-1.1.8 lib/asir/configuration.rb
asir-1.1.7 lib/asir/configuration.rb
asir-1.1.6 lib/asir/configuration.rb
asir-1.1.5 lib/asir/configuration.rb
asir-1.1.4 lib/asir/configuration.rb