Module: TrailerVote::Api::Composable::Get

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



10
11
12
13
14
15
# File 'lib/trailer_vote/api/composable/get.rb', line 10

def self.included(base)
  base.include Common
  base.class_eval do
    attr_accessor :result
  end
end

Instance Method Details

#dataObject

Return the decoded result inner object

Returns:

  • (Object)

    the inner object



46
47
48
# File 'lib/trailer_vote/api/composable/get.rb', line 46

def data
  raise format('Missing implementation of #data in %<name>s', self.class.name)
end

#etagString, NilClass

Return the ETag value

Returns:

  • (String, NilClass)

    the etag or nil



40
41
42
# File 'lib/trailer_vote/api/composable/get.rb', line 40

def etag
  call.result[Headers::ETAG]
end

Return the Links for the result

Returns:



19
20
21
22
# File 'lib/trailer_vote/api/composable/get.rb', line 19

def links
  # TODO: or headers
  @links ||= Links.new(data[:_links])
end

#to_hHash, Array

Decode the result via TypeRegistry. This also takes care of MediaTypes validation.

Returns:

  • (Hash, Array)

    the decoded response

See Also:

  • #decode


28
29
30
# File 'lib/trailer_vote/api/composable/get.rb', line 28

def to_h
  @to_h ||= TrailerVote::Api.decode(call.result)
end

#to_iNumeric

Return the HTTP status

Returns:

  • (Numeric)

    the HTTP status



34
35
36
# File 'lib/trailer_vote/api/composable/get.rb', line 34

def to_i
  call.result.status
end