Module: NucleusRails::ResponseAdapter

Extended by:
ActiveSupport::Concern
Includes:
ActionController::ImplicitRender, ActionController::MimeResponds, NucleusCore::Responder
Defined in:
lib/nucleus_rails/response_adapter.rb

Instance Method Summary collapse

Instance Method Details

#render_csv(entity) ⇒ Object



38
39
40
# File 'lib/nucleus_rails/response_adapter.rb', line 38

def render_csv(entity)
  send_data(entity.content, entity.to_h.except(:content))
end

#render_json(entity) ⇒ Object

<Nucleus::ResponseAdapter> content: Hash, String headers: Hash status: Integer location: String



22
23
24
# File 'lib/nucleus_rails/response_adapter.rb', line 22

def render_json(entity)
  render(json: entity.content, **entity.to_h.except(:content))
end

#render_nothing(entity) ⇒ Object



42
43
44
# File 'lib/nucleus_rails/response_adapter.rb', line 42

def render_nothing(entity)
  head(:no_content, entity.to_h)
end

#render_pdf(entity) ⇒ Object



34
35
36
# File 'lib/nucleus_rails/response_adapter.rb', line 34

def render_pdf(entity)
  send_data(entity.content, entity.to_h.except(:content))
end

#render_text(entity) ⇒ Object



30
31
32
# File 'lib/nucleus_rails/response_adapter.rb', line 30

def render_text(entity)
  render(plain: entity.content, **entity.to_h.except(:content))
end

#render_xml(entity) ⇒ Object



26
27
28
# File 'lib/nucleus_rails/response_adapter.rb', line 26

def render_xml(entity)
  render(xml: entity.content, **entity.to_h.except(:content))
end