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, source, pattern) ⇒ Relation
constructor
A new instance of Relation.
- #patch(data = {}, params = {}) ⇒ Object
- #post(data = {}, params = {}) ⇒ Object
- #put(data = {}, params = {}) ⇒ Object
Constructor Details
#initialize(context, source, pattern) ⇒ Relation
Returns a new instance of Relation.
4 5 6 7 8 |
# File 'lib/restify/relation.rb', line 4 def initialize(context, source, pattern) @context = context @source = source @template = to_template(pattern) end |
Instance Method Details
#==(other) ⇒ Object
30 31 32 33 34 |
# File 'lib/restify/relation.rb', line 30 def ==(other) super || (other.is_a?(String) && @template.pattern == other) || (other.is_a?(String) && @source == other) end |
#delete(params = {}) ⇒ Object
14 15 16 |
# File 'lib/restify/relation.rb', line 14 def delete(params = {}) request :delete, nil, params end |
#expand(params) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/restify/relation.rb', line 36 def (params) params = convert params variables = extract! params uri = @template. variables uri.query_values = params if params.any? uri end |
#get(params = {}) ⇒ Object
10 11 12 |
# File 'lib/restify/relation.rb', line 10 def get(params = {}) request :get, nil, params end |
#patch(data = {}, params = {}) ⇒ Object
26 27 28 |
# File 'lib/restify/relation.rb', line 26 def patch(data = {}, params = {}) request :patch, data, params end |
#post(data = {}, params = {}) ⇒ Object
18 19 20 |
# File 'lib/restify/relation.rb', line 18 def post(data = {}, params = {}) request :post, data, params end |
#put(data = {}, params = {}) ⇒ Object
22 23 24 |
# File 'lib/restify/relation.rb', line 22 def put(data = {}, params = {}) request :put, data, params end |