Module: Lanes::API::HelperMethods
- Defined in:
- lib/lanes/api/helper_methods.rb
Instance Method Summary collapse
- #client_bootstrap_data ⇒ Object
- #csrf_token ⇒ Object
- #data ⇒ Object
- #error_as_json ⇒ Object
- #json_reply(response) ⇒ Object
- #lanes_api_url ⇒ Object
- #lanes_application_title ⇒ Object
- #lanes_javascript_tags ⇒ Object
- #lanes_stylesheet_tags ⇒ Object
- #request_origin ⇒ Object
Instance Method Details
#client_bootstrap_data ⇒ Object
18 19 20 |
# File 'lib/lanes/api/helper_methods.rb', line 18 def client_bootstrap_data Oj.dump(Extensions.client_bootstrap_data(self), mode: :compat) end |
#csrf_token ⇒ Object
22 23 24 |
# File 'lib/lanes/api/helper_methods.rb', line 22 def csrf_token Rack::Csrf.csrf_token(env) end |
#data ⇒ Object
39 40 41 |
# File 'lib/lanes/api/helper_methods.rb', line 39 def data @json_data ||= Oj.load( request.body.read ) end |
#error_as_json ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/lanes/api/helper_methods.rb', line 30 def error_as_json Lanes.logger.warn request.env['sinatra.error'] Oj.dump({ success: false, errors: { exception: request.env['sinatra.error']. }, message: request.env['sinatra.error']. }) end |
#json_reply(response) ⇒ Object
47 48 49 50 |
# File 'lib/lanes/api/helper_methods.rb', line 47 def json_reply( response ) content_type 'application/json' Oj.dump(response, mode: :compat) end |
#lanes_api_url ⇒ Object
26 27 28 |
# File 'lib/lanes/api/helper_methods.rb', line 26 def lanes_api_url Lanes.config.api_path end |
#lanes_application_title ⇒ Object
6 7 8 |
# File 'lib/lanes/api/helper_methods.rb', line 6 def lanes_application_title Extensions.controlling.title end |
#lanes_javascript_tags ⇒ Object
10 11 12 |
# File 'lib/lanes/api/helper_methods.rb', line 10 def javascript_tag('lanes/vendor') + "\n" + javascript_tag('lanes') end |
#lanes_stylesheet_tags ⇒ Object
14 15 16 |
# File 'lib/lanes/api/helper_methods.rb', line 14 def stylesheet_tag('lanes') end |
#request_origin ⇒ Object
43 44 45 |
# File 'lib/lanes/api/helper_methods.rb', line 43 def request_origin @request_origin ||= env['HTTP_ORIGIN'] end |