Class: Ghee::API::Gists::Proxy

Inherits:
ResourceProxy show all
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

Methods inherited from ResourceProxy

accept_header, #all, #all_parallel, #build_prefix, #initialize, #method_missing, #paginate, #raw, #subject

Methods included from CUD

#create, #destroy, #patch

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

#publicObject

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

#starObject

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

#starredObject

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

Returns:

  • (Boolean)


49
50
51
# File 'lib/ghee/api/gists.rb', line 49

def starred?
  connection.get("#{path_prefix}/star").status == 204
end

#unstarObject

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