Sha256: 2ae8b6b88bb855f53f944b9368fc58c750cfd5a1301214a35e51d5f26781019b

Contents?: true

Size: 820 Bytes

Versions: 4

Compression:

Stored size: 820 Bytes

Contents

#!/usr/bin/env ruby -wKU

require 'configurability'


### Mixin that can be applied to classes to cause them to configure themselves
### as soon as they are able to.
module Configurability::DeferredConfig

	### Extension hook: log when the mixin is used.
	def self::extended( mod )
		Configurability.log.debug "Adding deferred configuration hook to %p" % [ mod ]
		super
	end


	### Singleton method definition hook: configure the instance as soon as it
	### overrides the #configure method supplied by the Configurability mixin itself.
	def singleton_method_added( sym )
		super

		if sym == :configure
			config = Configurability.loaded_config
			Configurability.log.debug "Propagating config to %p" % [ self ]
			Configurability.install_config( config, self )
		end
	end

end # module Configurability::DeferredConfig

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
configurability-1.0.6 lib/configurability/deferredconfig.rb
configurability-1.0.5 lib/configurability/deferredconfig.rb
configurability-1.0.4 lib/configurability/deferredconfig.rb
configurability-1.0.3 lib/configurability/deferredconfig.rb