Module: MismatchInspectable
- Defined in:
- lib/mismatch_inspectable/hash_formatter.rb,
lib/mismatch_inspectable/array_formatter.rb,
lib/mismatch_inspectable/mismatch_inspectable.rb
Defined Under Namespace
Modules: ClassMethods
Classes: ArrayFormatter, HashFormatter
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(base) ⇒ Object
7
8
9
10
11
|
# File 'lib/mismatch_inspectable/mismatch_inspectable.rb', line 7
def included(base)
class << base
include ClassMethods
end
end
|
Instance Method Details
#compare_methods ⇒ Object
36
37
38
|
# File 'lib/mismatch_inspectable/mismatch_inspectable.rb', line 36
def compare_methods
self.class.compare_methods
end
|
#inspect_mismatch(other, recursive: false, include_class: true, prefix: '', format: :array) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/mismatch_inspectable/mismatch_inspectable.rb', line 22
def inspect_mismatch(other, recursive: false, include_class: true, prefix: '', format: :array)
return if self.class != other.class
formatter = case format
when :hash then HashFormatter.new
when :array then ArrayFormatter.new
when :object then ObjectFormatter.new
else raise ArgumentError, "Invalid format: #{format}"
end
process_attributes(formatter, other, recursive, include_class, prefix, format)
formatter.mismatches
end
|