Sha256: 529e992be49685439103748a394a15c9e0fea0420a7fcb2760d36c2c20d67ae7

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

class Restly::Client < OAuth2::Client

  attr_accessor :id, :secret, :site
  attr_reader :format

  def initialize(*args, &block)
    opts = args.extract_options!
    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 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

7 entries across 7 versions & 1 rubygems

Version Path
restly-0.0.1.alpha.16 lib/restly/client.rb
restly-0.0.1.alpha.12 lib/restly/client.rb
restly-0.0.1.alpha.11 lib/restly/client.rb
restly-0.0.1.alpha.10 lib/restly/client.rb
restly-0.0.1.alpha.9 lib/restly/client.rb
restly-0.0.1.alpha.8 lib/restly/client.rb
restly-0.0.1.alpha.7 lib/restly/client.rb