Module: Route
- Defined in:
- lib/primate/route.rb
Class Method Summary collapse
- .call_js(scope_id, verb, js_req, helpers, session, i18n) ⇒ Object
- .clear(id = nil) ⇒ Object
- .registry(id = nil) ⇒ Object
- .scope(id) ⇒ Object
- .set_i18n(i18n) ⇒ Object
- .set_session(session, helpers) ⇒ Object
Class Method Details
.call_js(scope_id, verb, js_req, helpers, session, i18n) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/primate/route.rb', line 43 def call_js(scope_id, verb, js_req, helpers, session, i18n) set_session(session, helpers) set_i18n(i18n) verb_up = verb.to_s.upcase entry = @registry.dig(scope_id.to_s, verb_up) return Response.error(status: 404) unless entry request = Request.new(js_req, helpers) entry[:handler].call(request) end |
.clear(id = nil) ⇒ Object
18 19 20 21 22 |
# File 'lib/primate/route.rb', line 18 def clear(id = nil) target = (id || @current_scope).to_s @registry.delete(target) @registry[target] = {} end |
.registry(id = nil) ⇒ Object
24 25 26 |
# File 'lib/primate/route.rb', line 24 def registry(id = nil) @registry[(id || @current_scope).to_s] end |
.scope(id) ⇒ Object
13 14 15 16 |
# File 'lib/primate/route.rb', line 13 def scope(id) @current_scope = id.to_s @registry[@current_scope] end |
.set_i18n(i18n) ⇒ Object
39 40 41 |
# File 'lib/primate/route.rb', line 39 def set_i18n(i18n) I18N.set_current(i18n) end |
.set_session(session, helpers) ⇒ Object
35 36 37 |
# File 'lib/primate/route.rb', line 35 def set_session(session, helpers) PrimateInternal.set_session(session, helpers) end |