Module: Deimos::Utils::SchemaControllerMixin::ClassMethods

Defined in:
lib/deimos/utils/schema_controller_mixin.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#namespace(name) ⇒ Object

Set the namespace for both requests and responses.

Parameters:

  • name (String)


52
53
54
55
# File 'lib/deimos/utils/schema_controller_mixin.rb', line 52

def namespace(name)
  request_namespace(name)
  response_namespace(name)
end

#namespacesHash<Symbol, String>

Returns:

  • (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.

Parameters:

  • name (String)


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.

Parameters:

  • name (String)


65
66
67
# File 'lib/deimos/utils/schema_controller_mixin.rb', line 65

def response_namespace(name)
  namespaces[:response] = name
end

#schema_mappingHash<String, Hash<Symbol, String>>

Returns:

  • (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.

Parameters:

  • actions (Symbol)
  • kwactions (String)
  • request (String) (defaults to: nil)
  • response (String) (defaults to: nil)


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