Class: Ghee::API::Repos::Contents::Proxy

Inherits:
ResourceProxy show all
Defined in:
lib/ghee/api/contents.rb

Instance Attribute Summary collapse

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

#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 Attribute Details

#pathObject

Returns the value of attribute path.



17
18
19
# File 'lib/ghee/api/contents.rb', line 17

def path
  @path
end

Instance Method Details

#create(message, content = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ghee/api/contents.rb', line 18

def create(message, content=nil)
  if content.nil?
    message.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
    attributes = { path: path }.merge message
    attributes[:content] = Base64.encode64 attributes[:content]
  else
    attributes = {
      path: path,
      message: message, 
      content: Base64.encode64(content)
    }
  end
  connection.put(path_prefix, attributes).body
end