Method: Arbor::Model::Abstract#refresh_data

Defined in:
lib/arbor/model/abstract.rb

#refresh_dataObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/arbor/model/abstract.rb', line 20

def refresh_data
  raise "No API client configured for this resource" if api_client.nil?
  raise "No entity_type set for this resource" if entity_type.nil?
  raise "No known endpoint for this resource" if href.nil?

  data = api_client.get(href)

  entity_type_lower = entity_type.tr('_', '-').camelize(:lower).tr('-', '_')
  parsed_attributes = Serialiser.parse_attributes(data[entity_type_lower])
  load_attributes(parsed_attributes)
  attach_client(self.api_client)

  @attribute_lock = true
end