Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
Hide CallSettings as private. (#39)
Browse files Browse the repository at this point in the history
In Ruby, a 'private constant' is a constant which will have
to be accessed without prefix. So all entties inside of
Google::Gax can still access it as-is, but outside the module
it can't be accessed as Google::Gax::CallSettings.

This affects the tests, so this patch introduced a renaming
to toplevel ::CallSettings in a way to avoid violating
access of private constant.

updates googleapis/gax-python#112
  • Loading branch information
jmuk authored Aug 18, 2016
1 parent 5ff79c3 commit 6426db7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/google/gax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
require 'google/gax/version'

module Google
# Gax defines Google API extensions
module Gax
# rubocop:disable Metrics/ParameterLists

Expand Down Expand Up @@ -142,6 +143,8 @@ def merge(options)
end
end

private_constant :CallSettings

# Encapsulates the overridable settings for a particular API call
# @!attribute [r] timeout
# @return [Numeric, :OPTION_INHERIT]
Expand Down
7 changes: 6 additions & 1 deletion lib/google/gax/bundling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,20 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# rubocop:disable Style/Documentation
# Without this, somehow rubocop raises an warning for documentaion for
# module Gax, however it's documented in lib/google/gax.rb.

module Google
# Gax defines Google API extensions
module Gax
DEMUX_WARNING = [
'Warning: cannot demultiplex the bundled response, got ',
'%d subresponses; want %d, each bundled request will ',
'receive all responses'
].join

# rubocop:enable Style/Documentation

# Helper function for #compute_bundle_id.
# Used to retrieve a nested field signified by name where dots in name
# indicate nested objects.
Expand Down
11 changes: 9 additions & 2 deletions spec/google/gax/api_callable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ def initialize(msg, code)
FAKE_STATUS_CODE_1 = :FAKE_STATUS_CODE_1
FAKE_STATUS_CODE_2 = :FAKE_STATUS_CODE_2

describe Google::Gax do
CallSettings = Google::Gax::CallSettings
# Google::Gax::CallSettings is private, only accessible in the module context.
# For testing purpose, this makes a toplevel ::CallSettings point to the same
# class.
module Google
module Gax
::CallSettings = CallSettings
end
end

describe Google::Gax do
describe 'create_api_call' do
it 'calls api call' do
settings = CallSettings.new
Expand Down

0 comments on commit 6426db7

Please sign in to comment.