lib/configliere/define.rb in configliere-0.0.9 vs lib/configliere/define.rb in configliere-0.1.0

- old
+ new

@@ -9,15 +9,18 @@ # @example # Settings.define :dest_time, :type => Date, :description => 'Arrival time. If only a date is given, the current time of day on that date is assumed.' # Settings.define 'delorean.power_source', :description => 'Delorean subsytem supplying power to the Flux Capacitor.' # Settings.define :password, :required => true, :obscure => true # - def define param, definitions={} + def define param, definitions={}, &block self.param_definitions[param].merge! definitions - self.use(:env_var) if definitions.include?(:env_var) - self.use(:encrypted) if definitions.include?(:encrypted) + self.use(:env_var) if definitions.include?(:env_var) + self.use(:encrypted) if definitions.include?(:encrypted) + self.use(:config_block) if definitions.include?(:finally) self[param] = definitions[:default] if definitions.include?(:default) self.env_vars param => definitions[:env_var] if definitions.include?(:env_var) + self.finally(&definitions[:finally]) if definitions.include?(:finally) + self.finally(&block) if block end def param_definitions # initialize the param_definitions as an auto-vivifying hash if it's never been set @param_definitions ||= Sash.new{|hsh, key| hsh[key] = Sash.new }