Class: Velibe::Status

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/velibe/db/models.rb

Class Method Summary collapse

Class Method Details

.create_from_json(json) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/velibe/db/models.rb', line 19

def self.create_from_json(json)
  # maybe pass by the station?
  status = self.create({status: json[:status], #§todo
                        available_bikes: json[:available_bikes],
                        available_bike_stands: json[:available_bike_stands],
                        bike_stands: json[:bike_stands],
                        last_update: json[:last_update]}) #§see: convert
  # TODO: voir si objet de base marche

  status.station = Station.find_by_number(json[:number])

end