Module: JSONAPI::Serializable::Resource::Type::DSL

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

Overview

DSL methods for declaring the resource type.

Instance Method Summary collapse

Instance Method Details

#inherited(klass) ⇒ Object



34
35
36
37
38
# File 'lib/jsonapi/serializable/resource/type.rb', line 34

def inherited(klass)
  super
  klass.type_val   = type_val
  klass.type_block = type_block
end

#type(value) ⇒ Object #type(&block) ⇒ Object

Overloads:

  • #type(value) ⇒ Object

    Declare the JSON API type of this resource.

    Examples:

    type 'users'

    Parameters:

    • value (String)

      The value of the type.

  • #type(&block) ⇒ Object

    Declare the JSON API type of this resource.

    Examples:

    type do
      @object.type
    end

    Yield Returns:

    • (String)

      The value of the type.



54
55
56
57
# File 'lib/jsonapi/serializable/resource/type.rb', line 54

def type(value = nil, &block)
  self.type_val   = value.to_sym if value
  self.type_block = block
end