Class: UdSync::Sentinel

Inherits:
Object
  • Object
show all
Defined in:
lib/ud_sync/sentinel.rb

Instance Method Summary collapse

Constructor Details

#initialize(model, options) ⇒ Sentinel

Returns a new instance of Sentinel.



4
5
6
7
# File 'lib/ud_sync/sentinel.rb', line 4

def initialize(model, options)
  @model = model
  @options = options
end

Instance Method Details

#save_operationObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ud_sync/sentinel.rb', line 9

def save_operation
  operation = if model.destroyed?
                :delete
              else
                :save
              end

  UdSync::Operation.create(
    name:        operation,
    record_id:   model.id,
    external_id: external_id,
    owner_id:    owner_id,
    entity_name: operation_name
  )
end