Class: Inkdit::Resource
- Inherits:
-
Object
- Object
- Inkdit::Resource
- Defined in:
- lib/inkdit/resource.rb
Overview
some resource (in the REST sense) in the system
Direct Known Subclasses
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
the URL of this resource.
Instance Method Summary collapse
- #==(other_resource) ⇒ Object
-
#fetch! ⇒ Object
retrieve this resource using its URL.
-
#initialize(client, opts) ⇒ Resource
constructor
A new instance of Resource.
- #inspect ⇒ Object
Constructor Details
#initialize(client, opts) ⇒ Resource
Returns a new instance of Resource.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/inkdit/resource.rb', line 9 def initialize(client, opts) @client = client if opts.is_a? String @url = opts @params = [] else self.params = opts end end |
Instance Attribute Details
#url ⇒ Object (readonly)
the URL of this resource
5 6 7 |
# File 'lib/inkdit/resource.rb', line 5 def url @url end |
Instance Method Details
#==(other_resource) ⇒ Object
26 27 28 |
# File 'lib/inkdit/resource.rb', line 26 def ==(other_resource) self.url == other_resource.url end |
#fetch! ⇒ Object
retrieve this resource using its URL.
21 22 23 24 |
# File 'lib/inkdit/resource.rb', line 21 def fetch! response = @client.get(self.url) @params = response.parsed end |
#inspect ⇒ Object
30 31 32 |
# File 'lib/inkdit/resource.rb', line 30 def inspect "#<#{self.class.inspect} params=#{@params}>" end |