Class: Cachai::Admin

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/cachai.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Admin

Returns a new instance of Admin.



218
219
220
221
222
# File 'lib/cachai.rb', line 218

def initialize(opts = {})
  require 'tilt/erb'
  Cachai.load_db!
  super
end

Instance Method Details

#deliver(obj, view) ⇒ Object



261
262
263
264
265
266
267
# File 'lib/cachai.rb', line 261

def deliver(obj, view)
  if request.xhr?
    json(obj)
  else
    erb view
  end
end

#json(obj) ⇒ Object



269
270
271
272
# File 'lib/cachai.rb', line 269

def json(obj)
  content_type 'application/json'
  return obj.is_a?(String) ? obj : obj.to_json
end