module Datmachine
Constants
- VERSION
Attributes
client[RW]
config[RW]
hypermedia_registry[RW]
Public Class Methods
configure(api_key=nil, site_id=nil, options={})
click to toggle source
# File lib/datmachine.rb, line 28 def configure(api_key=nil, site_id=nil, options={}) @config = @config.merge(options) @client = Datmachine::Client.new(api_key, site_id, @config) end
from_href(href)
click to toggle source
# File lib/datmachine.rb, line 49 def from_href(href) split_uri = split_the_href(href) split_uri.reverse!.each do |resource| cls = Datmachine.hypermedia_registry[resource] return cls unless cls.nil? end end
from_hypermedia_registry(resource_name)
click to toggle source
# File lib/datmachine.rb, line 41 def from_hypermedia_registry(resource_name) cls = Datmachine.hypermedia_registry[resource_name] if cls.nil? raise 'OH SHIT' end cls end
get(*args, &block)
click to toggle source
# File lib/datmachine.rb, line 63 def get(*args, &block) self.client.get *args end
is_collection(href)
click to toggle source
# File lib/datmachine.rb, line 57 def is_collection(href) split_uri = split_the_href(href) split_uri.last.to_i == 0 end
is_configured_with_api_key?()
click to toggle source
# File lib/datmachine.rb, line 33 def is_configured_with_api_key? !@client.api_key.nil? end
post(*args, &block)
click to toggle source
# File lib/datmachine.rb, line 67 def post(*args, &block) self.client.post *args end
put(*args, &block)
click to toggle source
# File lib/datmachine.rb, line 71 def put(*args, &block) self.client.put *args end
split_the_href(href)
click to toggle source
# File lib/datmachine.rb, line 37 def split_the_href(href) URI.parse(href).path.sub(/\/$/, '').split('/') end
unstore(*args, &block)
click to toggle source
# File lib/datmachine.rb, line 75 def unstore(*args, &block) self.client.unstore *args end
Also aliased as: delete