class Amber::Storage::Json

Public Class Methods

new(model, file_name) click to toggle source
Calls superclass method Amber::Storage::new
# File lib/amber/storage/json.rb, line 4
def initialize(model, file_name)
  super model, Amber::Storage::Driver::File.new(file_name)
  if @driver.mount
    @status = true
  end
  @data = {}
end

Public Instance Methods

delete(id) click to toggle source
# File lib/amber/storage/json.rb, line 26
def delete(id)
  
end
generate(data) click to toggle source
# File lib/amber/storage/json.rb, line 46
def generate(data)
  begin
    JSON.generate data
  rescue Exception => e
    p e
  end
end
get(id) click to toggle source
# File lib/amber/storage/json.rb, line 12
def get(id)
  self.refresh
  @data[id.to_s]
end
parse(data) click to toggle source
# File lib/amber/storage/json.rb, line 38
def parse(data)
  begin
    JSON.parse data
  rescue Exception => e
    p e
  end
end
patch(id, model) click to toggle source
# File lib/amber/storage/json.rb, line 22
def patch(id, model)
  
end
post(model) click to toggle source
# File lib/amber/storage/json.rb, line 17
def post(model)
  self.refresh
  @data[model.id]
end
refresh() click to toggle source
# File lib/amber/storage/json.rb, line 30
def refresh
  data = @driver.read
  data = self.parse data
  if data
    @data = data
  end
end