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

option to enable/disable debugging output #5

Open
wants to merge 1 commit 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/ecircle/api.rb
Expand Up @@ -19,6 +19,12 @@ class Api

# @private
def client

Savon.configure do |config|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're mutating the global state of the Savon and HTTPI classes in a method which is supposed to be called multiple times. This is definitely not the place to do it. A more appropriate place could be after this line, but I still don't think this gem should mutate global state of other gems' main modules.

We should just configure our instance of Savon::Client as described here.

As for HTTPI, I'd not touch it at all, or do it only in the Ecircle.configure method.

The patch could also use some tests.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree with @exviva

config.log = Ecircle.configuration.debug
end
HTTPI.log = Ecircle.configuration.debug

@client ||= Savon::Client.new do
wsdl.document = Ecircle.configuration.wsdl
wsdl.endpoint = Ecircle.configuration.endpoint
Expand Down
3 changes: 2 additions & 1 deletion lib/ecircle/configuration.rb
Expand Up @@ -5,13 +5,14 @@ class Configuration
NAMESPACE = "http://webservices.ecircleag.com/rpcns"

# @private
attr_accessor :user, :password, :sync_realm, :async_realm, :wsdl, :endpoint, :namespace
attr_accessor :user, :password, :sync_realm, :async_realm, :wsdl, :endpoint, :namespace, :debug

# @private
def initialize
@wsdl = WSDL
@endpoint = ENDPOINT
@namespace = NAMESPACE
@debug = false
end
end
end