lib/ruby-conf.rb in ruby-conf-1.1.0 vs lib/ruby-conf.rb in ruby-conf-1.3.0
- old
+ new
@@ -10,11 +10,13 @@
end
def method_missing(name, *args, &block)
case(args.size)
when 0:
- if @attributes.has_key? name.to_sym
+ if block_given?
+ @attributes[name.to_sym] = RubyConf.define(&block)
+ elsif @attributes.has_key? name.to_sym
value = @attributes[name.to_sym]
if value.is_a?(Proc)
value.call
else
@@ -52,14 +54,14 @@
# end
#
#
# @param [Symbol] namespace of the config
# @param [Hash] list of options. e.g. :as => ConstantName
- def self.define(name, options = {}, &block)
+ def self.define(name = nil , options = {}, &block)
config = Config.new
- @@configs[name.to_sym] = config
config.instance_eval &block
+ @@configs[name.to_sym] = config unless name.nil?
if options.has_key? :as
Object.const_set(options[:as].to_s.to_sym, config)
end
config
end