Module: Leftovers::ComparableInstance

Included in:
Matchers::All, Matchers::And, Matchers::Any, Matchers::NodeHasAnyKeywordArgument, Matchers::NodeHasAnyPositionalArgumentWithValue, Matchers::NodeHasPositionalArgument, Matchers::NodeHasPositionalArgumentWithValue, Matchers::NodeHasReceiver, Matchers::NodeName, Matchers::NodePairKey, Matchers::NodePairValue, Matchers::NodePath, Matchers::NodePrivacy, Matchers::NodeScalarValue, Matchers::NodeType, Matchers::Not, Matchers::Or, Matchers::Path, Processors::AddDynamicPrefix, Processors::AddDynamicSuffix, Processors::AddPrefix, Processors::AddSuffix, Processors::Camelize, Processors::Capitalize, Processors::Deconstantize, Processors::DeleteAfter, Processors::DeleteAfterLast, Processors::DeleteBefore, Processors::DeleteBeforeLast, Processors::DeletePrefix, Processors::DeleteSuffix, Processors::Demodulize, Processors::Downcase, Processors::Each, Processors::EachForDefinitionSet, Processors::EachKeyword, Processors::EachKeywordArgument, Processors::EachPositionalArgument, Processors::EachPositionalArgumentFrom, Processors::Itself, Processors::KeywordArgument, Processors::MatchCurrentNode, Processors::MatchMatchedNode, Processors::Parameterize, Processors::Pluralize, Processors::PositionalArgument, Processors::Receiver, Processors::ReplaceValue, Processors::SetDefaultPrivacy, Processors::SetPrivacy, Processors::Singularize, Processors::Split, Processors::Swapcase, Processors::Titleize, Processors::Underscore, Processors::Upcase
Defined in:
lib/leftovers/comparable_instance.rb

Instance Method Summary collapse

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


5
6
7
8
9
10
11
# File 'lib/leftovers/comparable_instance.rb', line 5

def eql?(other)
  frozen? && other.frozen? &&
    self.class == other.class &&
    instance_variables.all? do |var|
      instance_variable_get(var) == other.instance_variable_get(var)
    end
end

#hashObject



14
15
16
# File 'lib/leftovers/comparable_instance.rb', line 14

def hash
  self.class.hash
end