Class: Cpro::Entities::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/cpro/entities/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload = nil) ⇒ Base

Returns a new instance of Base.



12
13
14
# File 'lib/cpro/entities/base.rb', line 12

def initialize(payload = nil)
  @payload = payload.is_a?(Hash) ? payload : {}
end

Instance Attribute Details

#payloadObject (readonly)

Returns the value of attribute payload.



10
11
12
# File 'lib/cpro/entities/base.rb', line 10

def payload
  @payload
end

Instance Method Details

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



20
21
22
# File 'lib/cpro/entities/base.rb', line 20

def ==(other)
  other.instance_of?(self.class) && other.payload == payload
end

#hashObject



25
26
27
# File 'lib/cpro/entities/base.rb', line 25

def hash
  [self.class, payload].hash
end

#to_hObject



16
17
18
# File 'lib/cpro/entities/base.rb', line 16

def to_h
  payload
end