Sha256: e1ec5cb02051eeb03066969e59d8e50fc4c36ce98c3e55be2c361acc24e740e7
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
module Restfulie::Client#:nodoc module EntryPoint include HTTP::RequestMarshaller extend self def recipe(converter_sym, options={}, &block) raise 'Undefined block' unless block_given? converter = "Restfulie::Common::Converter::#{converter_sym.to_s.camelize}".constantize converter.describe_recipe(options[:name], &block) end @resources_configurations = {} def configuration_of(resource_name) @resources_configurations[resource_name] end def configuration_for(resource_name,configuration = Configuration.new) yield configuration if block_given? @resources_configurations[resource_name] = configuration end def retrieve(resource_name) returning Object.new do |resource| resource.extend(Base) resource.configure end end end module Base include HTTP::RequestMarshaller def self.included(base)#:nodoc base.extend(self) end def uses_restfulie(configuration = Configuration.new,&block) EntryPoint.configuration_for(resource_name,configuration,&block) configure end def configure configuration = EntryPoint.configuration_of(resource_name) raise "Undefined configuration for #{resource_name}" unless configuration at(configuration.entry_point) configuration.representations.each do |representation_name,representation| register_representation(representation_name,representation) end end def resource_name @resource_name || @resource_name = self.class.to_s.to_sym end end end # Shortcut to Restfulie::Client::EntryPoint module Restfulie extend Restfulie::Client::EntryPoint def self.at(uri) Object.new.send(:extend, Restfulie::Client::EntryPoint).at(uri) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
restfulie-0.8.0 | lib/restfulie/client/base.rb |