Class: GitGoggles::App

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

Instance Method Summary collapse

Instance Method Details

#json(type, object) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/git_goggles/app.rb', line 48

def json(type, object)
  halt 404, "#{type.to_s.capitalize} not found" if object.nil?

  json = object.to_json

  if params[:callback]
    content_type 'text/javascript'
    "#{params[:callback]}(#{json});"
  else
    content_type :json
    json
  end
end