Class: Mangadex::Relationship

Inherits:
MangadexObject show all
Defined in:
lib/mangadex/relationship.rb

Instance Attribute Summary collapse

Attributes included from Internal::WithAttributes

#relationships

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MangadexObject

attributes_to_inspect, #eq?, #hash, #initialize

Constructor Details

This class inherits a constructor from Mangadex::MangadexObject

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



4
5
6
# File 'lib/mangadex/relationship.rb', line 4

def attributes
  @attributes
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/mangadex/relationship.rb', line 4

def id
  @id
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/mangadex/relationship.rb', line 4

def type
  @type
end

Class Method Details

.from_data(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mangadex/relationship.rb', line 7

def from_data(data)
  data = data.with_indifferent_access
  klass = class_for_relationship_type(data['type'])

  return klass.from_data(data) if klass && data['attributes']&.any?

  new(
    id: data['id'],
    type: data['type'],
    attributes: OpenStruct.new(data['attributes']),
  )
end

Instance Method Details

#inspectObject



42
43
44
# File 'lib/mangadex/relationship.rb', line 42

def inspect
  "#<#{self.class} id=#{id.inspect} type=#{type.inspect}>"
end