Class: Storage::Algolia::Actions::Create

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationService

process

Constructor Details

#initialize(model_name:, params:) ⇒ Create

Returns a new instance of Create.



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

def initialize(model_name:, params:)
  @model_name = model_name
  @params = params
end

Instance Attribute Details

#model_nameObject (readonly)

Returns the value of attribute model_name.



9
10
11
# File 'lib/storage/algolia/actions/create.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/create.rb', line 9

def params
  @params
end

Instance Method Details

#processObject

Raises:

  • (Exception)


16
17
18
19
20
21
22
23
# File 'lib/storage/algolia/actions/create.rb', line 16

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

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