Module: Yast2::Equatable::ClassMethods

Defined in:
library/general/src/lib/yast2/equatable.rb

Overview

Class methods for defining the attributes to consider when comparing objects

Instance Method Summary collapse

Instance Method Details

#eql_attr(*names) ⇒ Object

Saves the name of the attributes to use when comparing objects

Parameters:

  • names (Array<Symbol>)


81
82
83
84
# File 'library/general/src/lib/yast2/equatable.rb', line 81

def eql_attr(*names)
  @eql_attrs ||= []
  @eql_attrs += names
end

#eql_attrsArray<Symbol>

Name of the attributes to consider when comparing objects

Returns:

  • (Array<Symbol>)


74
75
76
# File 'library/general/src/lib/yast2/equatable.rb', line 74

def eql_attrs
  @eql_attrs || []
end

#inherited(subclass) ⇒ Object

Inherited classes must remember the attributes for comparison from its parent class



65
66
67
68
69
# File 'library/general/src/lib/yast2/equatable.rb', line 65

def inherited(subclass)
  super

  subclass.eql_attr(*eql_attrs)
end