Method: Welo::IdentifyingMatcher#match?
- Defined in:
- lib/welo/core/matcher.rb
#match?(resource, ident = :default) ⇒ Boolean Also known as: =~
Returns true if the params hash qualifies for identifying this resource. prefixing is possible in case the hash’s keys has prefixes e.g., Foo = Struct.new(:a, :b) do
include Resource
identify :default, :a, :b
end
foo = Foo.new(1,2)
params = { 'bla.a' => 1, 'bla.b' => 2 }
Matcher.new(params, 'bla.').match?(foo, :default)
# => true
see Resource#identifiers and identifiers_for_params_matching for more on prefix.
64 65 66 67 68 69 70 71 |
# File 'lib/welo/core/matcher.rb', line 64 def match?(resource, ident=:default) return false if wrong_params_set?(resource, ident) pairs = [resource.identify(ident), identifiers_for_params_matching(resource, ident)].transpose pairs.inject(true) do |bool, pair| sym, param_name = *pair bool and resource.send(sym) == params[param_name] end end |