Sha256: 447287ca9bb17cf614018292db2714e87830883c766995747110e5eb8ce30244
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 KB
Contents
require 'finix/version' unless defined? Finix::VERSION require 'finix/client' require 'finix/error' module Finix @client = nil @config = {:root_url => 'https://localhost/processing'} @hypermedia_registry = {} @errors_registry = { :unknown => Finix::ResourceErrors, 400 => Finix::BadRequest, 401 => Finix::Unauthorized, 403 => Finix::Forbidden, 404 => Finix::NotFound, 405 => Finix::MethodNotAllowed, 422 => Finix::UnprocessableEntity, 500 => Finix::ServerError } class << self attr_accessor :client attr_accessor :config attr_accessor :hypermedia_registry attr_accessor :errors_registry def configure(options={}) unless options[:root_url].nil? @config = {} end @config = @config.merge(options) @config[:user] = @config[:user].strip unless @config[:user].nil? @config[:password] = @config[:password].strip unless @config[:password].nil? @client = Finix::Client.new @config end def split_the_href(href) URI.parse(href).path.sub(/\/$/, '').split('/') end def get_href(cls) href = Finix.hypermedia_registry.key(cls) href = Finix.hypermedia_registry.key(cls.superclass) if href.nil? href end def from_hypermedia_registry(href, attributes={}) split_uri = split_the_href(href) split_uri.reverse!.each do |resource| cls = Finix.hypermedia_registry[resource] cls = cls.send :hypermedia_subtype, attributes if not cls.nil? and cls.respond_to?(:hypermedia_subtype) return cls unless cls.nil? end Finix::UnknownResource end def get(*args, &block) self.client.get *args end def post(*args, &block) self.client.post *args end def put(*args, &block) self.client.put *args end end end require 'finix/resources'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
finix-0.11 | lib/finix.rb |