Class: Pillow::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/pillow/resource.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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.expand(url).to_s
  else
    url.to_s
  end
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/pillow/resource.rb', line 8

def url
  @url
end

Class Method Details

.deleteObject



56
57
58
# File 'lib/pillow/resource.rb', line 56

def delete
  @delete ||= Pillow::Method.new(:delete, self)
end

.getObject



40
41
42
# File 'lib/pillow/resource.rb', line 40

def get
  @get ||= Pillow::Method.new(:get, self)
end

.headObject



44
45
46
# File 'lib/pillow/resource.rb', line 44

def head
  @head ||= Pillow::Method.new(:head, self)
end

.headersObject



27
28
29
# File 'lib/pillow/resource.rb', line 27

def headers
  @headers ||= {}
end

.optionsObject



36
37
38
# File 'lib/pillow/resource.rb', line 36

def options
  @options ||= Pillow::Method.new(:options, self)
end

.patchObject



64
65
66
# File 'lib/pillow/resource.rb', line 64

def patch
  @patch ||= Pillow::Method.new(:patch, self)
end

.postObject



48
49
50
# File 'lib/pillow/resource.rb', line 48

def post
  @post ||= Pillow::Method.new(:post, self)
end

.putObject



52
53
54
# File 'lib/pillow/resource.rb', line 52

def put
  @put ||= Pillow::Method.new(:put, self)
end

.query_valuesObject



23
24
25
# File 'lib/pillow/resource.rb', line 23

def query_values
  @query_values ||= {}
end

.sessionObject



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

.traceObject



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 options(*args)
  self.class.options.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