Module: Deimos::Utils::SchemaControllerMixin::ClassMethods
- Defined in:
- lib/deimos/utils/schema_controller_mixin.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#namespace(name) ⇒ Object
Set the namespace for both requests and responses.
- #namespaces ⇒ Hash<Symbol, String>
-
#request_namespace(name) ⇒ Object
Set the namespace for requests.
-
#response_namespace(name) ⇒ Object
Set the namespace for repsonses.
- #schema_mapping ⇒ Hash<String, Hash<Symbol, String>>
-
#schemas(*actions, request: nil, response: nil, **kwactions) ⇒ Object
Indicate which schemas should be assigned to actions.
Instance Method Details
#namespace(name) ⇒ Object
Set the namespace for both requests and responses.
52 53 54 55 |
# File 'lib/deimos/utils/schema_controller_mixin.rb', line 52 def namespace(name) request_namespace(name) response_namespace(name) end |
#namespaces ⇒ Hash<Symbol, String>
46 47 48 |
# File 'lib/deimos/utils/schema_controller_mixin.rb', line 46 def namespaces @namespaces ||= {} end |
#request_namespace(name) ⇒ Object
Set the namespace for requests.
59 60 61 |
# File 'lib/deimos/utils/schema_controller_mixin.rb', line 59 def request_namespace(name) namespaces[:request] = name end |
#response_namespace(name) ⇒ Object
Set the namespace for repsonses.
65 66 67 |
# File 'lib/deimos/utils/schema_controller_mixin.rb', line 65 def response_namespace(name) namespaces[:response] = name end |
#schema_mapping ⇒ Hash<String, Hash<Symbol, String>>
25 26 27 |
# File 'lib/deimos/utils/schema_controller_mixin.rb', line 25 def schema_mapping @schema_mapping ||= {} end |
#schemas(*actions, request: nil, response: nil, **kwactions) ⇒ Object
Indicate which schemas should be assigned to actions.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/deimos/utils/schema_controller_mixin.rb', line 34 def schemas(*actions, request: nil, response: nil, **kwactions) actions.each do |action| request ||= action.to_s.titleize response ||= action.to_s.titleize schema_mapping[action.to_s] = { request: request, response: response } end kwactions.each do |key, val| schema_mapping[key.to_s] = { request: val, response: val } end end |