module SiteHub::Equality

Public Class Methods

included(clazz) click to toggle source
# File lib/sitehub/equality.rb, line 12
def self.included(clazz)
  clazz.extend(ClassMethods)
end

Public Instance Methods

==(other) click to toggle source
# File lib/sitehub/equality.rb, line 16
def ==(other)
  return false unless other.is_a?(_clazz)
  fields = instance_variables.find_all { |field| !_clazz.transient_fields.include?(field) }
  fields.all? do |variable|
    instance_variable_get(variable) == other.instance_variable_get(variable)
  end
end
_clazz() click to toggle source
# File lib/sitehub/equality.rb, line 24
def _clazz
  self.class
end