Class: Shaf::ALPS::RelationSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/shaf/alps/relation_serializer.rb

Constant Summary collapse

SAFE_METHODS =
['GET', 'HEAD', 'OPTIONS']
IDEMPOTENT_METHODS =
['PUT', 'PATCH', 'DELETE']
UNSAFE_METHODS =
['POST']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rel) ⇒ RelationSerializer

Returns a new instance of RelationSerializer.



16
17
18
# File 'lib/shaf/alps/relation_serializer.rb', line 16

def initialize(rel)
  @rel = rel
end

Instance Attribute Details

#relObject (readonly)

Returns the value of attribute rel.



10
11
12
# File 'lib/shaf/alps/relation_serializer.rb', line 10

def rel
  @rel
end

Class Method Details

.call(arg) ⇒ Object



12
13
14
# File 'lib/shaf/alps/relation_serializer.rb', line 12

def self.call(arg)
  new(arg).to_hash
end

Instance Method Details

#to_hashObject



20
21
22
23
24
25
# File 'lib/shaf/alps/relation_serializer.rb', line 20

def to_hash
  {
    id: rel.id,
    type: type,
  }.merge(optional_properties)
end