Module: LinkedRails::Controller

Extended by:
ActiveSupport::Concern
Includes:
ActiveResponse::Controller::Collections, ActiveResponse::Controller::CrudDefaults, ActiveResponse::Controller::Params, Pundit
Included in:
Rails::WelcomeController
Defined in:
lib/linked_rails/controller.rb,
lib/linked_rails/controller/authorization.rb,
lib/linked_rails/controller/error_handling.rb,
lib/linked_rails/active_response/controller.rb

Defined Under Namespace

Modules: Authorization, ClassMethods, ErrorHandling

Instance Method Summary collapse

Instance Method Details

#_render_with_renderer_json(record, options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/linked_rails/active_response/controller.rb', line 16

def _render_with_renderer_json(record, options)
  self.content_type = Mime[:json]

  return record if record.is_a?(String)
  return record.to_json if record.is_a?(Hash)

  serializer_opts = RDF::Serializers::Renderers.transform_opts(
    options,
    serializer_params
  )

  serializer = RDF::Serializers.serializer_for(record)&.new(record, serializer_opts)
  return record.to_json unless serializer

  Oj.dump(serializer.serializable_hash, mode: :compat)
end

#serializer_paramsObject



33
34
35
# File 'lib/linked_rails/active_response/controller.rb', line 33

def serializer_params
  {}
end