Class: BooticClient::Relation

Inherits:
Object
  • Object
show all
Defined in:
lib/bootic_client/relation.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs, client, wrapper_class = Entity) ⇒ Relation

Returns a new instance of Relation.



8
9
10
# File 'lib/bootic_client/relation.rb', line 8

def initialize(attrs, client, wrapper_class = Entity)
  @attrs, @client, @wrapper_class = attrs, client, wrapper_class
end

Class Method Details

.expand(href, opts = {}) ⇒ Object



48
49
50
# File 'lib/bootic_client/relation.rb', line 48

def self.expand(href, opts = {})
  URITemplate.new(href).expand(opts)
end

Instance Method Details

#docs ⇒ Object



36
37
38
# File 'lib/bootic_client/relation.rb', line 36

def docs
  attrs['docs']
end

#get(opts = {}) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/bootic_client/relation.rb', line 40

def get(opts = {})
  if templated?
    client.get_and_wrap uri.expand(opts), wrapper_class
  else
    client.get_and_wrap href, wrapper_class, opts
  end
end

#href ⇒ Object



16
17
18
# File 'lib/bootic_client/relation.rb', line 16

def href
  attrs['href']
end

#inspect ⇒ Object



12
13
14
# File 'lib/bootic_client/relation.rb', line 12

def inspect
  %(#<#{self.class.name} #{attrs.inspect}>)
end

#name ⇒ Object



24
25
26
# File 'lib/bootic_client/relation.rb', line 24

def name
  attrs['name']
end

#templated? ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/bootic_client/relation.rb', line 20

def templated?
  !!attrs['templated']
end

#title ⇒ Object



28
29
30
# File 'lib/bootic_client/relation.rb', line 28

def title
  attrs['title']
end

#type ⇒ Object



32
33
34
# File 'lib/bootic_client/relation.rb', line 32

def type
  attrs['type']
end