Module: WildcardMatchers::Matchers
- Included in:
- WildcardMatchers
- Defined in:
- lib/wildcard_matchers/matchers.rb,
lib/wildcard_matchers/matchers/bag.rb,
lib/wildcard_matchers/matchers/is_uri.rb,
lib/wildcard_matchers/matchers/hash_includes.rb,
lib/wildcard_matchers/matchers/with_uri_template.rb
Defined Under Namespace
Classes: BagOf, HashIncludes, IsUri, WithUriTemplate
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.define_wildcard_matcher(name, &block) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/wildcard_matchers/matchers.rb', line 6
def define_wildcard_matcher(name, &block)
if block_given?
define_method(name, &block)
else
define_method(name) do |*args|
::WildcardMatchers::Matchers.const_get(name.to_s.camelcase(:upper)).new(args)
end
end
end
|
.define_wildcard_matcher_with_proc(name, &block) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/wildcard_matchers/matchers.rb', line 16
def define_wildcard_matcher_with_proc(name, &block)
raise "no block defined" unless block_given?
define_method(name) do
block
end
end
|
Instance Method Details
#is_a_member_of(*args) ⇒ Object
53
54
55
56
57
|
# File 'lib/wildcard_matchers/matchers.rb', line 53
def is_a_member_of(*args)
lambda do |item|
args.flatten.any? {|expected| expected === item }
end
end
|
#is_uri(hash = {}) ⇒ Object
5
6
7
|
# File 'lib/wildcard_matchers/matchers/is_uri.rb', line 5
def is_uri(hash = {})
IsUri.new(hash)
end
|