Module: Plumb::Equality

Defined in:
lib/plumb/composable.rb

Overview

Override #=== and #== for Composable instances. but only when included in classes, not extended.

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object



102
103
104
# File 'lib/plumb/composable.rb', line 102

def ==(other)
  other.is_a?(self.class) && other.respond_to?(:children) && other.children == children
end

#===(other) ⇒ Boolean

‘#===` equality. So that Plumb steps can be used in case statements and pattern matching.

Parameters:

  • other (Object)

Returns:

  • (Boolean)


93
94
95
96
97
98
99
100
# File 'lib/plumb/composable.rb', line 93

def ===(other)
  case other
  when Composable
    other == self
  else
    resolve(other).valid?
  end
end