Class: Rerout::Models::BatchLinkResult

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

Overview

Outcome of one link in a ‘links.create_batch` call. `index` is the input position; `ok` is true on success (then `code` is set), false on failure (then `error` carries the reason).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index:, ok:, code: nil, error: nil) ⇒ BatchLinkResult

Returns a new instance of BatchLinkResult.



613
614
615
616
617
618
619
# File 'lib/rerout/models.rb', line 613

def initialize(index:, ok:, code: nil, error: nil)
  @index = index
  @ok = ok
  @code = code
  @error = error
  freeze
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



611
612
613
# File 'lib/rerout/models.rb', line 611

def code
  @code
end

#errorObject (readonly)

Returns the value of attribute error.



611
612
613
# File 'lib/rerout/models.rb', line 611

def error
  @error
end

#indexObject (readonly)

Returns the value of attribute index.



611
612
613
# File 'lib/rerout/models.rb', line 611

def index
  @index
end

#okObject (readonly)

Returns the value of attribute ok.



611
612
613
# File 'lib/rerout/models.rb', line 611

def ok
  @ok
end

Class Method Details

.from_hash(hash) ⇒ Object



621
622
623
624
625
626
627
628
# File 'lib/rerout/models.rb', line 621

def self.from_hash(hash)
  new(
    index: hash['index'],
    ok: hash['ok'],
    code: hash['code'],
    error: hash['error']
  )
end

Instance Method Details

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



634
635
636
# File 'lib/rerout/models.rb', line 634

def ==(other)
  other.is_a?(BatchLinkResult) && other.to_h == to_h
end

#hashObject



639
640
641
# File 'lib/rerout/models.rb', line 639

def hash
  to_h.hash
end

#to_hObject



630
631
632
# File 'lib/rerout/models.rb', line 630

def to_h
  { index: index, ok: ok, code: code, error: error }
end