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) ⇒ void

This method returns an undefined value.

Set the namespace for both requests and responses.

Parameters:

  • name (String)


54
55
56
57
# File 'lib/deimos/utils/schema_controller_mixin.rb', line 54

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

#namespacesHash<Symbol, String>

Returns:

  • (Hash<Symbol, String>)


47
48
49
# File 'lib/deimos/utils/schema_controller_mixin.rb', line 47

def namespaces
  @namespaces ||= {}
end

#request_namespace(name) ⇒ void

This method returns an undefined value.

Set the namespace for requests.

Parameters:

  • name (String)


62
63
64
# File 'lib/deimos/utils/schema_controller_mixin.rb', line 62

def request_namespace(name)
  namespaces[:request] = name
end

#response_namespace(name) ⇒ void

This method returns an undefined value.

Set the namespace for repsonses.

Parameters:

  • name (String)


69
70
71
# File 'lib/deimos/utils/schema_controller_mixin.rb', line 69

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) ⇒ void

This method returns an undefined value.

Indicate which schemas should be assigned to actions.

Parameters:

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


35
36
37
38
39
40
41
42
43
44
# File 'lib/deimos/utils/schema_controller_mixin.rb', line 35

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