Module: Boundy::Comparators

Extended by:
Punchout::Punchable
Defined in:
lib/boundy/comparators.rb

Class Method Summary collapse

Class Method Details

.add(type, comparator) ⇒ Object



11
12
13
14
# File 'lib/boundy/comparators.rb', line 11

def self.add(type, comparator)
  matchable = Punchout::Matcher::Klass.new(type).punches(comparator)
  puncher.add(matchable)
end

.comparator(datum, subject) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/boundy/comparators.rb', line 16

def self.comparator(datum,subject)
  comparator = if subject.respond_to?(:comparator)
                 subject.comparator
               else
                 puncher.punch(subject.class)
               end

  comparator.new(datum, subject)
rescue
  raise "I can't compare myself to a #{subject.class}: #{subject.inspect}"
end