Module: Grape::EndpointExtension

Defined in:
lib/grape-active_model_serializers/endpoint_extension.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#controller_nameObject

Returns the value of attribute controller_name


9
10
11
# File 'lib/grape-active_model_serializers/endpoint_extension.rb', line 9

def controller_name
  @controller_name
end

Class Method Details

.included(base) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/grape-active_model_serializers/endpoint_extension.rb', line 27

def self.included(base)
  mattr_accessor :_serialization_scope
  self._serialization_scope = :current_user

  base.class_eval do
    def serialization_scope
      return unless _serialization_scope
      return unless respond_to?(_serialization_scope, true)
      send(_serialization_scope)
    end
  end
end

Instance Method Details

#default_serializer_optionsObject


53
54
# File 'lib/grape-active_model_serializers/endpoint_extension.rb', line 53

def default_serializer_options
end

#namespace_optionsObject


11
12
13
14
15
16
17
# File 'lib/grape-active_model_serializers/endpoint_extension.rb', line 11

def namespace_options
  if respond_to?(:inheritable_setting)
    inheritable_setting.namespace
  else
    settings[:namespace] ? settings[:namespace].options : {}
  end
end

#render(resources, extra_options = {}) ⇒ Object


40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/grape-active_model_serializers/endpoint_extension.rb', line 40

def render(resources, extra_options = {})
  options = extra_options.symbolize_keys
  env['ams_meta'] = options.slice(
    :meta, :meta_key
  )
  env['ams_adapter'] = options.slice(
    :adapter, :serializer, :each_serializer, :include,
    :fields, :key_transform, :links, :namespace
  )
  env['ams_extra'] = options[:extra]
  resources
end

#route_optionsObject


19
20
21
22
23
24
25
# File 'lib/grape-active_model_serializers/endpoint_extension.rb', line 19

def route_options
  if respond_to?(:inheritable_setting)
    inheritable_setting.route
  else
    options[:route_options]
  end
end

#url_optionsObject


56
57
# File 'lib/grape-active_model_serializers/endpoint_extension.rb', line 56

def url_options
end