Class: OrangeData::Transport::IntermediateResult

Inherits:
Object
  • Object
show all
Defined in:
lib/orange_data/transport.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(success: false, sub_url: nil, data:, attempt_retry: false, retry_in: nil, retry_count: 0, transport: nil, errors: nil) ⇒ IntermediateResult

Returns a new instance of IntermediateResult.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/orange_data/transport.rb', line 70

def initialize(
  success:false, sub_url:nil, data:,
  attempt_retry:false, retry_in:nil, retry_count:0, transport:nil,
  errors:nil
)
  @success = success
  @sub_url = sub_url
  @data = data
  @attempt_retry = attempt_retry
  @retry_in = retry_in
  @retry_count = retry_count
  @transport = transport
  @errors = errors
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



85
86
87
# File 'lib/orange_data/transport.rb', line 85

def errors
  @errors
end

#retry_countObject (readonly)

Returns the value of attribute retry_count.



85
86
87
# File 'lib/orange_data/transport.rb', line 85

def retry_count
  @retry_count
end

#retry_inObject (readonly)

Returns the value of attribute retry_in.



85
86
87
# File 'lib/orange_data/transport.rb', line 85

def retry_in
  @retry_in
end

Instance Method Details

#retryObject



95
96
97
98
99
100
# File 'lib/orange_data/transport.rb', line 95

def retry
  raise "not-retriable" unless should_retry?

  @transport.post_entity(@sub_url, @data,
    raise_errors:false, result_class:self.class, retry_count:(retry_count + 1))
end

#should_retry?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/orange_data/transport.rb', line 91

def should_retry?
  @attempt_retry || false
end

#success?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/orange_data/transport.rb', line 87

def success?
  @success == true
end