Module: JSONAPI::Serializable::Resource::Id::DSL

Defined in:
lib/jsonapi/serializable/resource/id.rb

Overview

DSL methods for declaring the resource id.

Instance Method Summary collapse

Instance Method Details

#id(&block) ⇒ Object

Declare the JSON API id of this resource.

Examples:

id { @user.id.to_s }

Yield Returns:

  • (String)

    The id of the resource.



41
42
43
# File 'lib/jsonapi/serializable/resource/id.rb', line 41

def id(&block)
  self.id_block = block
end

#inherited(klass) ⇒ Object



30
31
32
33
# File 'lib/jsonapi/serializable/resource/id.rb', line 30

def inherited(klass)
  super
  klass.id_block = id_block
end