16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/muve-store-mongo/formatter.rb', line 16
def self.convert_from_storeable_object(storeable, klass=nil)
if klass
return {
id: storeable[:id],
name: storeable[:name],
location: (Location.new({
latitude: storeable[:location]["coordinates"][1],
longitude: storeable[:location]["coordinates"][0]
}) if storeable[:location] && storeable[:location]["coordinates"])
} if (klass < Muve::Place)
return {
id: storeable[:id],
time: storeable[:time],
traveller: Traveller.new(name: storeable[:traveller]),
location: Location.new(
latitude: storeable[:location]["coordinates"][1],
longitude: storeable[:location]["coordinates"][0]
)
} if (klass < Muve::Movement)
end
if storeable.kind_of? Hash
if Helper.symbolize_keys(storeable).to_a.include? [:type, 'Place']
Location.new(latitude: storeable[:coordinates][1], longitude: storeable[:coordinates][0]) if storeable[:coordinates]
end
end
end
|