Class: Rerout::Models::RecordedConversion

Inherits:
Object
  • Object
show all
Defined in:
lib/rerout/models.rb

Overview

Result of recording a conversion via ‘POST /v1/conversions`. `recorded` is true when stored; `duplicate` is true when an identical conversion for the same click had already been recorded (the call is idempotent).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recorded:, duplicate:) ⇒ RecordedConversion

Returns a new instance of RecordedConversion.



580
581
582
583
584
# File 'lib/rerout/models.rb', line 580

def initialize(recorded:, duplicate:)
  @recorded = recorded
  @duplicate = duplicate
  freeze
end

Instance Attribute Details

#duplicateObject (readonly)

Returns the value of attribute duplicate.



578
579
580
# File 'lib/rerout/models.rb', line 578

def duplicate
  @duplicate
end

#recordedObject (readonly)

Returns the value of attribute recorded.



578
579
580
# File 'lib/rerout/models.rb', line 578

def recorded
  @recorded
end

Class Method Details

.from_hash(hash) ⇒ Object



586
587
588
589
590
591
# File 'lib/rerout/models.rb', line 586

def self.from_hash(hash)
  new(
    recorded: hash.fetch('recorded', false),
    duplicate: hash.fetch('duplicate', false)
  )
end

Instance Method Details

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



597
598
599
# File 'lib/rerout/models.rb', line 597

def ==(other)
  other.is_a?(RecordedConversion) && other.recorded == recorded && other.duplicate == duplicate
end

#hashObject



602
603
604
# File 'lib/rerout/models.rb', line 602

def hash
  [self.class, recorded, duplicate].hash
end

#to_hObject



593
594
595
# File 'lib/rerout/models.rb', line 593

def to_h
  { recorded: recorded, duplicate: duplicate }
end