Module: G5IntegrationsUpdatable::FindOrCreateFromFeed::ClassMethods

Defined in:
app/concerns/g5_integrations_updatable/find_or_create_from_feed.rb

Instance Method Summary collapse

Instance Method Details

#find_or_create_from_feed(location_settings_hash) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/concerns/g5_integrations_updatable/find_or_create_from_feed.rb', line 5

def find_or_create_from_feed(location_settings_hash)
  hash    = location_settings_hash.dup
  setting = find_or_initialize_by(uid: hash.delete('uid'))
  setting.update_attributes(
      urn:                      hash.delete('urn'),
      location_uid:             hash.delete('location_uid'),
      location_urn:             hash.delete('location_urn'),
      location_name:            hash.delete('location_name'),
      client_uid:               hash.delete('client_uid'),
      client_urn:               hash.delete('client_urn'),
      client_name:              hash.delete('client_name'),
      strategy_type:            hash.delete('strategy_type'),
      job_frequency_in_minutes: hash.delete('job_frequency_in_minutes'),
      properties:               hash
  )
  setting
end