Sha256: bd95e37d9afaae58a2f4785aeb9c23db6e73e104c7337bf80faa06971753e22a
Contents?: true
Size: 1.39 KB
Versions: 2
Compression:
Stored size: 1.39 KB
Contents
class Restly::Client < OAuth2::Client attr_accessor :id, :secret, :site attr_reader :format, :resource def initialize(*args, &block) opts = args.extract_options! opts.merge!(raise_errors: false) self.resource = opts.delete(:resource) if opts[:resource] self.id = args[0] || Restly::Configuration.oauth_options[:client_id] self.secret = args[1] || Restly::Configuration.oauth_options[:client_secret] self.site = opts.delete(:site) || Restly::Configuration.site self.options = Restly::Configuration.client_options.merge(opts) self.ssl = opts.delete(:ssl) || Restly::Configuration.ssl self.format = @format = opts.delete(:format) || Restly::Configuration.default_format self.options[:connection_build] ||= block end def resource=(resource) raise InvalidObject, "Resource must be a descendant of Restly::Base" unless resource.ancestors.include?(Restly::Base) @resource = resource end def resource_name resource.name.parameterize end def ssl=(val) self.options[:connection_opts][:ssl] = val if val end def format=(val) self.options[:connection_opts][:headers] = { "Accept" => "application/#{format}", "Content-Type" => "application/#{format}" } end Restly::Configuration.client_options.keys.each do |m| define_method "#{m}=" do |val| self.options[m] = val end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
restly-0.0.1.alpha.19 | lib/restly/client.rb |
restly-0.0.1.alpha.18 | lib/restly/client.rb |