Class: Mocatra::App
- Inherits:
-
Sinatra::Application
- Object
- Sinatra::Application
- Mocatra::App
- Defined in:
- lib/mocatra.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.record_path ⇒ Object
10 11 12 |
# File 'lib/mocatra.rb', line 10 def self.record_path @record_path || File.("../../records", __FILE__) end |
.record_path=(path) ⇒ Object
14 15 16 |
# File 'lib/mocatra.rb', line 14 def self.record_path=(path) @record_path = path end |
Instance Method Details
#my_song(request) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/mocatra.rb', line 38 def my_song(request) if request.content_type =~ /json/ json = JSON.parse request.body.read request.path_info = json["method"] end logger.info path: request.path_info, parameters: json || request.body.read if Record.exist?(request.path_info) record = Record.sing(request.path_info) status record['status'] record['body'].to_json else status 404 end end |