Class: DeepClassCompare::Matcher
- Inherits:
-
Object
- Object
- DeepClassCompare::Matcher
show all
- Defined in:
- lib/deep_class_compare/matcher.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(base) ⇒ Matcher
Returns a new instance of Matcher.
10
11
12
13
|
# File 'lib/deep_class_compare/matcher.rb', line 10
def initialize(base)
@base = base
raise_class_required_error! unless @base.is_a?(Class)
end
|
Class Method Details
.build(klass) ⇒ Object
3
4
5
6
7
8
|
# File 'lib/deep_class_compare/matcher.rb', line 3
def self.build(klass)
if klass.ancestors.include?(Array) then ArrayMatcher.new(klass)
elsif klass.ancestors.include?(Hash) then HashMatcher.new(klass)
else new(klass)
end
end
|
Instance Method Details
#match?(value) ⇒ Boolean
15
16
17
|
# File 'lib/deep_class_compare/matcher.rb', line 15
def match?(value)
value.is_a?(@base)
end
|