Class: FakeApi::Handler
- Inherits:
-
Object
- Object
- FakeApi::Handler
- Defined in:
- lib/fake_api/handler.rb
Class Method Summary collapse
- .handle(method, path:, params: {}, headers: {}, session: {}, cookies: {}) ⇒ Object
- .result(data:, status: 200, headers: {}, cookies: {}, session: {}) ⇒ Object
Class Method Details
.handle(method, path:, params: {}, headers: {}, session: {}, cookies: {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fake_api/handler.rb', line 4 def Handler.handle(method, path:, params: {}, headers: {}, session: {}, cookies: {}) if route = Handler.resolve(method, path) result( data: route.response.call, status: route.status, headers: route.headers, cookies: route., session: route.session ) else # READ MORE: https://github.com/igorkasyanchuk/fake_api result( data: %Q{ Route "#{FakeApi::Engine.mounted_in}/#{path}" was not found. Please edit your fake_api rounting file(s) in app/fake_api/*.rb.\n\nAvailable: \n#{available.presence || 'NONE'} }.strip, status: 500, ) end end |
.result(data:, status: 200, headers: {}, cookies: {}, session: {}) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/fake_api/handler.rb', line 25 def Handler.result(data:, status: 200, headers: {}, cookies: {}, session: {}) OpenStruct.new( data: data, status: status, headers: headers, cookies: , session: session ) end |