lib/mustermann/expander.rb in mustermann-0.3.1 vs lib/mustermann/expander.rb in mustermann-0.4.0
- old
+ new
@@ -39,11 +39,11 @@
#
# @param [Array<#to_str, Mustermann::Pattern>] patterns list of to add for expansion, Strings will be compiled to patterns.
# @return [Mustermann::Expander] the expander
def add(*patterns)
patterns.each do |pattern|
- pattern = Mustermann.new(pattern.to_str, **@options) if pattern.respond_to? :to_str
+ pattern = Mustermann.new(pattern, **@options)
raise NotImplementedError, "expanding not supported for #{pattern.class}" unless pattern.respond_to? :to_ast
@api_expander.add(pattern.to_ast)
@patterns << pattern
end
self
@@ -135,10 +135,10 @@
# Values to use for expansion.
#
# @return [String] expanded string
# @raise [NotImplementedError] raised if expand is not supported.
# @raise [Mustermann::ExpandError] raised if a value is missing or unknown
- def expand(behavior = nil, **values)
+ def expand(behavior = nil, values = {})
behavior, values = nil, behavior if behavior.is_a? Hash
values = map_values(values)
case behavior || additional_values
when :raise then @api_expander.expand(values)