Class: Rails::Surrender::Render::Ids

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/surrender/render/ids.rb

Overview

Rendering the IDs of the requested resources.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ Ids

Returns a new instance of Ids.



10
11
12
# File 'lib/rails/surrender/render/ids.rb', line 10

def initialize(resource)
  @resource = resource
end

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource.



8
9
10
# File 'lib/rails/surrender/render/ids.rb', line 8

def resource
  @resource
end

Instance Method Details

#parseObject



14
15
16
17
# File 'lib/rails/surrender/render/ids.rb', line 14

def parse
  ids = resource.respond_to?(:ids) ? resource.ids : [resource.id]
  Response.new(data: { ids: ids })
end