lib/finix.rb in finix-0.7 vs lib/finix.rb in finix-0.8
- old
+ new
@@ -3,11 +3,11 @@
require 'finix/error'
module Finix
@client = nil
- @config = {:root_url=>'https://localhost/processing'}
+ @config = {:root_url => 'https://localhost/processing'}
@hypermedia_registry = {}
class << self
attr_accessor :client
@@ -28,28 +28,23 @@
def split_the_href(href)
URI.parse(href).path.sub(/\/$/, '').split('/')
end
- def from_hypermedia_registry(resource_name)
- cls = Finix.hypermedia_registry[resource_name]
- if cls.nil?
- return Finix::UnknownResource
- end
- cls
+ def get_href(cls)
+ href = Finix.hypermedia_registry.key(cls)
+ href = Finix.hypermedia_registry.key(cls.superclass) if href.nil?
+ href
end
- def from_href(href)
+ 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
- end
-
- def is_collection(href)
- split_uri = split_the_href(href)
- Finix.hypermedia_registry.has_key?(split_uri.last)
+ Finix::UnknownResource
end
def get(*args, &block)
self.client.get *args
end
\ No newline at end of file