Class: SimpleJsonapi::Serializer

Inherits:
Object
  • Object
show all
Includes:
SerializerMethods
Defined in:
lib/simple_jsonapi/serializer.rb

Overview

Subclass Serializer to create serializers for specific types of resources.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializerMethods

#definition, #with

Class Method Details

.attribute(name, options = {}) ⇒ void .attribute(name, options = {}, &block) ⇒ void #id(&block) ⇒ void #id(value) ⇒ void

Returns:

  • (void)
  • (void)


23
24
25
# File 'lib/simple_jsonapi/serializer.rb', line 23

def attribute(name, **options, &block)
  definition.attribute(name, **options, &block)
end

#has_many(name, description: nil, **options, &block) ⇒ void

This method returns an undefined value.

Parameters:

  • name (Symbol)
  • options (Hash)

    a customizable set of options

Yield Parameters:

  • resource (Object)

Yield Returns:

  • (Object, Array<Object>)

    The related resource or resources



41
42
43
# File 'lib/simple_jsonapi/serializer.rb', line 41

def has_many(name, **options, &block)
  definition.has_many(name, **options, &block)
end

#has_one(name, description: nil, **options, &block) ⇒ void

This method returns an undefined value.

Parameters:

  • name (Symbol)
  • options (Hash)

    a customizable set of options

Yield Parameters:

  • resource (Object)

Yield Returns:

  • (Object, Array<Object>)

    The related resource or resources



32
33
34
# File 'lib/simple_jsonapi/serializer.rb', line 32

def has_one(name, **options, &block)
  definition.has_one(name, **options, &block)
end

#id(&block) ⇒ void #id(value) ⇒ void

This method returns an undefined value.



8
9
10
# File 'lib/simple_jsonapi/serializer.rb', line 8

def id(*args, &block)
  definition.id(*args, &block)
end

This method returns an undefined value.



47
48
49
# File 'lib/simple_jsonapi/serializer.rb', line 47

def link(name, *args, **options, &block)
  definition.link(name, *args, **options, &block)
end

#meta(name, options = {}, &block) ⇒ void #meta(name, value, options = {}) ⇒ void

This method returns an undefined value.



53
54
55
# File 'lib/simple_jsonapi/serializer.rb', line 53

def meta(name, *args, **options, &block)
  definition.meta(name, *args, **options, &block)
end

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

This method returns an undefined value.



14
15
16
# File 'lib/simple_jsonapi/serializer.rb', line 14

def type(*args, &block)
  definition.type(*args, &block)
end

Instance Method Details

#attribute_definitionsHash{Symbol => Attribute}

Returns:

  • (Hash{Symbol => Attribute})


71
72
73
# File 'lib/simple_jsonapi/serializer.rb', line 71

def attribute_definitions
  definition.attribute_definitions
end

#id_definitionProc

Returns:

  • (Proc)


61
62
63
# File 'lib/simple_jsonapi/serializer.rb', line 61

def id_definition
  definition.id_definition
end

Returns:

  • (Hash{Symbol => String,Object})


81
82
83
# File 'lib/simple_jsonapi/serializer.rb', line 81

def link_definitions
  definition.link_definitions
end

#meta_definitionsHash{Symbol => String,Object}

Returns:

  • (Hash{Symbol => String,Object})


86
87
88
# File 'lib/simple_jsonapi/serializer.rb', line 86

def meta_definitions
  definition.meta_definitions
end

#relationship_definitionsHash{Symbol => Relationship}

Returns:

  • (Hash{Symbol => Relationship})


76
77
78
# File 'lib/simple_jsonapi/serializer.rb', line 76

def relationship_definitions
  definition.relationship_definitions
end

#type_definitionProc

Returns:

  • (Proc)


66
67
68
# File 'lib/simple_jsonapi/serializer.rb', line 66

def type_definition
  definition.type_definition
end