==(other)
click to toggle source
def ==(other)
__hash__ == other.__hash__
end
[](meth)
click to toggle source
def [](meth)
value = @table[meth.to_sym]
value = value.call if value.is_a? Proc
value
end
[]=(meth, value)
click to toggle source
def []=(meth, value)
@table[meth.to_sym] = value
end
__hash__()
click to toggle source
__replace__(options)
click to toggle source
def __replace__(options)
@table = __to_hash__(options).dup
end
__to_hash__(obj)
click to toggle source
def __to_hash__(obj)
Options === obj ? obj.__hash__ : obj
end
default(defaults = {})
click to toggle source
def default defaults = {}
@table = @table.reverse_merge!(__to_hash__(defaults))
end
method_missing(meth, *args, &block)
click to toggle source
def method_missing meth, *args, &block
if meth.to_s =~ %r^\w+=$/
raise ArgumentError, "Options does not support #{meth} without a single argument" if args.length != 1
self[meth.to_s.chop] = args.first
elsif meth.to_s =~ %r^\w+$/
if !@table.has_key?(meth)
begin; return super; rescue NoMethodError; nil; end
end
raise ArgumentError, "Options does not support #{meth} with arguments" if args.length != 0
self[meth]
else
super
end
end
respond_to?(meth)
click to toggle source
def respond_to?(meth)
super || meth.to_s =~ %r^\w+(=)?$/
end
respond_to_missing?(meth, private_method = false)
click to toggle source
def respond_to_missing?(meth, private_method = false)
meth.to_s =~ %r^\w+(=)?$/
end