Class: Mouth::Endoscope

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

Instance Method Summary collapse

Instance Method Details

#json_inputObject

Helpers



105
106
107
# File 'lib/mouth/endoscope.rb', line 105

def json_input
  Yajl::Parser.parse(request.env["rack.input"].read)
end

#render_json(attributables) ⇒ Object



109
110
111
112
113
114
115
116
117
# File 'lib/mouth/endoscope.rb', line 109

def render_json(attributables)
  content_type 'application/json'
  encodable = if attributables.is_a?(Array)
    attributables.collect(&:all_attributes)
  else
    attributables.all_attributes
  end
  Yajl::Encoder.encode(encodable)
end