Class: Welo::EpithetMatcher
Instance Attribute Summary
Attributes inherited from Matcher
#params, #prefix
Instance Method Summary
collapse
Methods inherited from Matcher
#initialize, #missing_params?, #too_many_params?, #wrong_params_set?
Constructor Details
This class inherits a constructor from Welo::Matcher
Instance Method Details
#epithets_for_params_matching(resource, epithet_resource, label) ⇒ Object
77
78
79
|
# File 'lib/welo/core/matcher.rb', line 77
def epithets_for_params_matching(resource, epithet_resource, label)
resource.epithets(label, prefix).map{|id| id.sub(/^:/,'')}
end
|
85
86
87
|
# File 'lib/welo/core/matcher.rb', line 85
def (resource, epithet_resource, label)
(params.keys - epithets_for_params_matching(resource, epithet_resource, label))
end
|
#match?(resource, epithet_resource, label) ⇒ Boolean
Also known as:
=~
89
90
91
92
93
94
95
96
97
|
# File 'lib/welo/core/matcher.rb', line 89
def match?(resource, epithet_resource, label)
return false if wrong_params_set?(resource, epithet_resource, label)
pairs = [resource.epithet(label),
epithets_for_params_matching(resource, epithet_resource, label)].transpose
pairs.inject(true) do |bool, pair|
sym, param_name = *pair
bool and resource.send(sym, epithet_resource) == params[param_name]
end
end
|
#missing_params(resource, epithet_resource, label) ⇒ Object
81
82
83
|
# File 'lib/welo/core/matcher.rb', line 81
def missing_params(resource, epithet_resource, label)
(epithets_for_params_matching(resource, epithet_resource, label) - params.keys)
end
|