Class: Restify::Relation
- Inherits:
-
Object
- Object
- Restify::Relation
- Defined in:
- lib/restify/relation.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #delete(params = {}) ⇒ Object
- #expand(params) ⇒ Object
- #get(params = {}) ⇒ Object
-
#initialize(context, template) ⇒ Relation
constructor
A new instance of Relation.
- #patch(data = {}, params = {}) ⇒ Object
- #post(data = {}, params = {}) ⇒ Object
- #put(data = {}, params = {}) ⇒ Object
Constructor Details
#initialize(context, template) ⇒ Relation
Returns a new instance of Relation.
4 5 6 7 |
# File 'lib/restify/relation.rb', line 4 def initialize(context, template) @context = context @template = Addressable::Template.new template end |
Instance Method Details
#==(other) ⇒ Object
29 30 31 |
# File 'lib/restify/relation.rb', line 29 def ==(other) super || (other.is_a?(String) && @template.pattern == other) end |
#delete(params = {}) ⇒ Object
13 14 15 |
# File 'lib/restify/relation.rb', line 13 def delete(params = {}) request :delete, nil, params end |
#expand(params) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/restify/relation.rb', line 33 def (params) params = convert params variables = extract! params uri = @template. variables uri.query_values = (uri.query_values || {}).merge params if params.any? @context.join uri end |
#get(params = {}) ⇒ Object
9 10 11 |
# File 'lib/restify/relation.rb', line 9 def get(params = {}) request :get, nil, params end |
#patch(data = {}, params = {}) ⇒ Object
25 26 27 |
# File 'lib/restify/relation.rb', line 25 def patch(data = {}, params = {}) request :patch, data, params end |
#post(data = {}, params = {}) ⇒ Object
17 18 19 |
# File 'lib/restify/relation.rb', line 17 def post(data = {}, params = {}) request :post, data, params end |
#put(data = {}, params = {}) ⇒ Object
21 22 23 |
# File 'lib/restify/relation.rb', line 21 def put(data = {}, params = {}) request :put, data, params end |