Sha256: 77acf0d66627bad4cc1d68e11c7a69aaec6fc032e360dfcafe29e5e592056834
Contents?: true
Size: 864 Bytes
Versions: 3
Compression:
Stored size: 864 Bytes
Contents
module C80MapFloors class MapJson < ActiveRecord::Base def self.update_json # открываем файл на чтение locations_path = Rails.root.join("public", "locations.json") locs = File.read(locations_path) locs_hash = JSON.parse(locs) # поместим в него детей - здания со всеми детьми и внуками buildings = [] C80MapFloors::MapBuilding.all.each do |building| buildings << building.as_json end locs_hash["buildings"] = buildings # запишем в файл File.open(locations_path, 'w') do |f| f.write(locs_hash.to_json) end end def self.fetch_json locations_path = Rails.root.join("public", "locations.json") locs = File.read(locations_path) JSON.parse(locs) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
c80_map_floors-0.1.0.3 | app/models/c80_map_floors/map_json.rb |
c80_map_floors-0.1.0.2 | app/models/c80_map_floors/map_json.rb |
c80_map_floors-0.1.0.1 | app/models/c80_map_floors/map_json.rb |