class Validate::Compare::WithAttributes
Public Class Methods
new(attributes)
click to toggle source
# File lib/validate/compare.rb, line 22 def initialize(attributes) @attributes = attributes end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/validate/compare.rb, line 26 def <=>(other) @attributes.each do |attribute, value| result = value <=> other.send(attribute) return result unless result.zero? end 0 end
method_missing(symbol, *args)
click to toggle source
Calls superclass method
# File lib/validate/compare.rb, line 35 def method_missing(symbol, *args) return super unless args.empty? && respond_to_missing?(symbol) @attributes[symbol] end
respond_to_missing?(attribute, _ = false)
click to toggle source
# File lib/validate/compare.rb, line 41 def respond_to_missing?(attribute, _ = false) @attributes.include?(attribute) end
to_s()
click to toggle source
# File lib/validate/compare.rb, line 45 def to_s '<attributes ' + @attributes.map { |attribute, value| "#{attribute}: #{value}"} .join(', ') + '>' end