Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for customizing Faraday middleware #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/pinterest/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ class Client
DEFAULT_USER_AGENT = "Pinterest Ruby Gem #{Pinterest::VERSION}".freeze
DEFAULT_ADAPTER = Faraday.default_adapter

def initialize(access_token = nil, connection_options={})
def initialize(access_token = nil, connection_options={}, &connection_config)
@access_token = access_token
@connection_options = connection_options
@connection_config = connection_config
end

attr_reader :access_token
Expand Down Expand Up @@ -79,6 +80,7 @@ def connection(raw = false, log = false)
connection.use Faraday::Response::ParseJson
connection.use Faraday::Request::UrlEncoded
connection.response :logger if log
@connection_config.call(connection) if @connection_config
connection.adapter(adapter)
end
end
Expand Down
2 changes: 1 addition & 1 deletion pinterest.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_development_dependency "bundler", "~> 1.10"
spec.add_development_dependency "bundler", "~> 2.0"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.3"
spec.add_development_dependency "vcr", "~> 2.9"
Expand Down