Class: Pillow::Resource
- Inherits:
-
Object
- Object
- Pillow::Resource
- Defined in:
- lib/pillow/resource.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
- .delete ⇒ Object
- .get ⇒ Object
- .head ⇒ Object
- .headers ⇒ Object
- .options ⇒ Object
- .patch ⇒ Object
- .post ⇒ Object
- .put ⇒ Object
- .query_values ⇒ Object
- .session ⇒ Object
- .template(template = nil) ⇒ Object
- .trace ⇒ Object
Instance Method Summary collapse
- #delete(*args) ⇒ Object
- #get(*args) ⇒ Object
- #head(*args) ⇒ Object
-
#initialize(url) ⇒ Resource
constructor
A new instance of Resource.
- #options(*args) ⇒ Object
- #patch(*args) ⇒ Object
- #post(*args) ⇒ Object
- #put(*args) ⇒ Object
- #trace(*args) ⇒ Object
Constructor Details
#initialize(url) ⇒ Resource
Returns a new instance of Resource.
10 11 12 13 14 15 16 |
# File 'lib/pillow/resource.rb', line 10 def initialize(url) @url = if url.is_a?(Hash) self.class.template.(url).to_s else url.to_s end end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/pillow/resource.rb', line 8 def url @url end |
Class Method Details
.delete ⇒ Object
56 57 58 |
# File 'lib/pillow/resource.rb', line 56 def delete @delete ||= Pillow::Method.new(:delete, self) end |
.get ⇒ Object
40 41 42 |
# File 'lib/pillow/resource.rb', line 40 def get @get ||= Pillow::Method.new(:get, self) end |
.head ⇒ Object
44 45 46 |
# File 'lib/pillow/resource.rb', line 44 def head @head ||= Pillow::Method.new(:head, self) end |
.headers ⇒ Object
27 28 29 |
# File 'lib/pillow/resource.rb', line 27 def headers @headers ||= {} end |
.options ⇒ Object
36 37 38 |
# File 'lib/pillow/resource.rb', line 36 def ||= Pillow::Method.new(:options, self) end |
.patch ⇒ Object
64 65 66 |
# File 'lib/pillow/resource.rb', line 64 def patch @patch ||= Pillow::Method.new(:patch, self) end |
.post ⇒ Object
48 49 50 |
# File 'lib/pillow/resource.rb', line 48 def post @post ||= Pillow::Method.new(:post, self) end |
.put ⇒ Object
52 53 54 |
# File 'lib/pillow/resource.rb', line 52 def put @put ||= Pillow::Method.new(:put, self) end |
.query_values ⇒ Object
23 24 25 |
# File 'lib/pillow/resource.rb', line 23 def query_values @query_values ||= {} end |
.session ⇒ Object
19 20 21 |
# File 'lib/pillow/resource.rb', line 19 def session @session ||= Patron::Session.new end |
.template(template = nil) ⇒ Object
31 32 33 34 |
# File 'lib/pillow/resource.rb', line 31 def template(template = nil) @template = Addressable::Template.new(template) if template @template end |
.trace ⇒ Object
60 61 62 |
# File 'lib/pillow/resource.rb', line 60 def trace @trace ||= Pillow::Method.new(:trace, self) end |
Instance Method Details
#delete(*args) ⇒ Object
89 90 91 |
# File 'lib/pillow/resource.rb', line 89 def delete(*args) self.class.delete.process(*args) end |
#get(*args) ⇒ Object
73 74 75 |
# File 'lib/pillow/resource.rb', line 73 def get(*args) self.class.get.process(*args) end |
#head(*args) ⇒ Object
77 78 79 |
# File 'lib/pillow/resource.rb', line 77 def head(*args) self.class.head.process(*args) end |
#options(*args) ⇒ Object
69 70 71 |
# File 'lib/pillow/resource.rb', line 69 def (*args) self.class..process(*args) end |
#patch(*args) ⇒ Object
97 98 99 |
# File 'lib/pillow/resource.rb', line 97 def patch(*args) self.class.patch.process(*args) end |
#post(*args) ⇒ Object
81 82 83 |
# File 'lib/pillow/resource.rb', line 81 def post(*args) self.class.post.process(*args) end |
#put(*args) ⇒ Object
85 86 87 |
# File 'lib/pillow/resource.rb', line 85 def put(*args) self.class.put.process(*args) end |
#trace(*args) ⇒ Object
93 94 95 |
# File 'lib/pillow/resource.rb', line 93 def trace(*args) self.class.trace.process(*args) end |