Class: Ghee::API::Gists::Proxy
- Inherits:
-
ResourceProxy
- Object
- ResourceProxy
- Ghee::API::Gists::Proxy
- Defined in:
- lib/ghee/api/gists.rb
Overview
Gists::Proxy inherits from Ghee::Proxy and enables defining methods on the proxy object
Instance Attribute Summary
Attributes inherited from ResourceProxy
#connection, #current_page, #id, #pagination, #params, #path_prefix, #total
Instance Method Summary collapse
- #comments(id = nil) ⇒ Object
-
#public ⇒ Object
Get public gists.
-
#star ⇒ Object
Star a gist.
-
#starred ⇒ Object
Get starred gists.
-
#starred? ⇒ Boolean
Returns whether gist is starred.
-
#unstar ⇒ Object
Unstar a gist.
Methods inherited from ResourceProxy
accept_header, #all, #all_parallel, #build_prefix, #initialize, #method_missing, #paginate, #raw, #subject
Methods included from CUD
Constructor Details
This class inherits a constructor from Ghee::ResourceProxy
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Ghee::ResourceProxy
Instance Method Details
#comments(id = nil) ⇒ Object
23 24 25 26 |
# File 'lib/ghee/api/gists.rb', line 23 def comments(id = nil) prefix = id ? "#{path_prefix}/comments/#{id}" : "#{path_prefix}/comments" return Ghee::API::Gists::Comments::Proxy.new connection, prefix end |
#public ⇒ Object
Get public gists
Returns json
57 58 59 |
# File 'lib/ghee/api/gists.rb', line 57 def public connection.get("#{path_prefix}/public").body end |
#star ⇒ Object
Star a gist
Returns true/false
33 34 35 |
# File 'lib/ghee/api/gists.rb', line 33 def star connection.put("#{path_prefix}/star").status == 204 end |
#starred ⇒ Object
Get starred gists
Returns json
65 66 67 |
# File 'lib/ghee/api/gists.rb', line 65 def starred connection.get("#{path_prefix}/starred").body end |
#starred? ⇒ Boolean
Returns whether gist is starred
Returns true/false
49 50 51 |
# File 'lib/ghee/api/gists.rb', line 49 def starred? connection.get("#{path_prefix}/star").status == 204 end |
#unstar ⇒ Object
Unstar a gist
Returns true/false
41 42 43 |
# File 'lib/ghee/api/gists.rb', line 41 def unstar connection.delete("#{path_prefix}/star").status == 204 end |