Skip to content

Commit

Permalink
Provides custom inspect method for Ezid::Configuration
Browse files Browse the repository at this point in the history
Tweaked Ezid::Client#inspect
  • Loading branch information
dchandekstark committed Feb 26, 2015
1 parent a5ce3ea commit 6cd2857
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ezid/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def initialize(opts = {})
end

def inspect
"#<#{self.class.name} connection=#{connection.inspect} " \
"user=\"#{user}\" session=#{logged_in? ? 'OPEN' : 'CLOSED'}>"
"#<#{self.class.name} connection=#{connection.inspect}, " \
"user=#{user.inspect}, session=#{logged_in? ? 'OPEN' : 'CLOSED'}>"
end

# The client configuration
Expand Down
6 changes: 6 additions & 0 deletions lib/ezid/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ def initialize
@default_shoulder = ENV["EZID_DEFAULT_SHOULDER"]
end

def inspect
ivars = instance_variables.reject { |v| v == :@password }
.map { |v| "#{v}=#{instance_variable_get(v).inspect}" }
"#<#{self.class.name} #{ivars.join(', ')}>"
end

def logger
@logger ||= Logger.new(STDERR)
end
Expand Down

0 comments on commit 6cd2857

Please sign in to comment.