Class: Storage::Algolia::Actions::Update

Inherits:
Base show all
Defined in:
lib/storage/algolia/actions/update.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationService

process

Constructor Details

#initialize(model_name:, params:, id:) ⇒ Update

Returns a new instance of Update.



11
12
13
14
15
16
# File 'lib/storage/algolia/actions/update.rb', line 11

def initialize(model_name:, params:, id:)
  @model_name = model_name
  @params = params
  @id = id
  @retries = 0
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/storage/algolia/actions/update.rb', line 9

def id
  @id
end

#model_nameObject (readonly)

Returns the value of attribute model_name.



9
10
11
# File 'lib/storage/algolia/actions/update.rb', line 9

def model_name
  @model_name
end

#paramsObject (readonly)

Returns the value of attribute params.



9
10
11
# File 'lib/storage/algolia/actions/update.rb', line 9

def params
  @params
end

#retriesObject (readonly)

Returns the value of attribute retries.



9
10
11
# File 'lib/storage/algolia/actions/update.rb', line 9

def retries
  @retries
end

Instance Method Details

#processObject

Raises:

  • (Exception)


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/storage/algolia/actions/update.rb', line 18

def process
  raise Exception unless task.dig('objectID')

  normalize original_object.to_hash.merge(
    {
      objectID: task.dig('objectID'),
      updatedAt: task.dig('updatedAt')
    },
    params
  )
end