lib/divining_rod/mappings.rb in divining_rod-0.6.2 vs lib/divining_rod/mappings.rb in divining_rod-0.6.3
- old
+ new
@@ -19,10 +19,14 @@
attr_reader :default_opts, :parent
def initialize(parent, default_opts = {})
@parent = parent
+ unless default_opts == {}
+ p "Passed in default_opts"
+ p default_opts
+ end
@default_opts = Mash.new(default_opts)
end
def pattern(type, pattern, opts = {})
definition = Matchers.send(type.to_sym, pattern, merged_opts(opts))
@@ -44,27 +48,27 @@
end
def method_missing(meth, *args, &blk)
# Lets us use map.ua instead of map.pattern :ua
if Matchers.respond_to?(meth.to_sym)
- self.pattern(meth, args[0], args[1,], &blk)
+ opts = args[1,] || {}
+ self.pattern(meth, args[0], opts, &blk)
else
super
end
end
private
def merged_opts(opts)
- opts = parent.opts.merge(opts)
opts = default_opts.merge(opts)
+ opts = parent.opts.merge(opts)
opts
end
def append_to_parent(definition)
parent.children << definition
definition
end
-
end
end