Class: JSON_ROA::Client::Relation

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conn, key, data) ⇒ Relation

Returns a new instance of Relation.



12
13
14
15
16
# File 'lib/json_roa/client/relation.rb', line 12

def initialize conn, key, data 
  @conn= conn
  @key= key
  @data= data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/json_roa/client/relation.rb', line 9

def data
  @data
end

#keyObject (readonly)

Returns the value of attribute key.



10
11
12
# File 'lib/json_roa/client/relation.rb', line 10

def key
  @key
end

Instance Method Details

#get(query_parameters = {}) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/json_roa/client/relation.rb', line 18

def get query_parameters= {}
  href= @data['href']
  template= ::Addressable::Template.new(href) 
  expanded= template.expand(query_parameters)
  response=@conn.get(expanded)
  ::JSON_ROA::Client::Resource.new(@conn,response)
end

#methodsObject



26
27
28
# File 'lib/json_roa/client/relation.rb', line 26

def methods 
  @data['methods']
end