Class: Storage::Algolia::Actions::Get
- Inherits:
-
Base
- Object
- ApplicationService
- Base
- Storage::Algolia::Actions::Get
- Defined in:
- lib/storage/algolia/actions/get.rb
Constant Summary collapse
- MAX_RETRIES =
3
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
-
#retries ⇒ Object
readonly
Returns the value of attribute retries.
Instance Method Summary collapse
-
#initialize(model_name:, id:) ⇒ Get
constructor
A new instance of Get.
- #process ⇒ Object
Methods inherited from ApplicationService
Constructor Details
#initialize(model_name:, id:) ⇒ Get
Returns a new instance of Get.
13 14 15 16 17 |
# File 'lib/storage/algolia/actions/get.rb', line 13 def initialize(model_name:, id:) @model_name = model_name @id = id @retries = 0 end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/storage/algolia/actions/get.rb', line 11 def id @id end |
#model_name ⇒ Object (readonly)
Returns the value of attribute model_name.
11 12 13 |
# File 'lib/storage/algolia/actions/get.rb', line 11 def model_name @model_name end |
#retries ⇒ Object (readonly)
Returns the value of attribute retries.
11 12 13 |
# File 'lib/storage/algolia/actions/get.rb', line 11 def retries @retries end |
Instance Method Details
#process ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/storage/algolia/actions/get.rb', line 19 def process @retries += 1 normalize index.get_object(id).deep_transform_keys(&:to_sym) rescue => e pp "Retrying (#{@retries}/#{MAX_RETRIES})..." sleep 2 retry if @retries <= MAX_RETRIES raise Exception end |