Sha256: f0f1db76a60cee9ab1681b6762e57da3c48967d2f977beb8d5b95ba6ded1a8fa

Contents?: true

Size: 1.53 KB

Versions: 32

Compression:

Stored size: 1.53 KB

Contents

require 'google/ads/google_ads/api_versions'
module Google
  module Ads
    module GoogleAds
      class LookupUtil

        def initialize
          @proto_lookup_utils = {}
          @path_lookup_utils = {}
        end

        # Returns a reference to the PathLookupUtil to generate resource names.
        def path(version)
          path_lookup_util(version)
        end

        private

        attr_reader :proto_lookup_utils, :path_lookup_utils

        # Load up the path lookup util for the given version, storing a copy
        # of it if this is the first time we needed it.
        def path_lookup_util(version)
          unless valid_version?(version)
            raise sprintf('Unknown version %s', version)
          end
          if path_lookup_utils[version].nil?
            path_version = version.downcase
            require sprintf('google/ads/google_ads/utils/%s/path_lookup_util',
                path_version)
            class_path = sprintf(
              'Google::Ads::GoogleAds::Utils::%s::PathLookupUtil',
              version
            )
            path_lookup_utils[version] = class_for_path(class_path).new
          end
          path_lookup_utils[version]
        end

        # Converts complete class path into class object.
        def class_for_path(path)
          path.split('::').inject(Kernel) do |scope, const_name|
            scope.const_get(const_name)
          end
        end

        def valid_version?(version)
          Google::Ads::GoogleAds.valid_version?(version)
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
google-ads-googleads-31.0.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-30.0.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-29.0.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-28.0.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-27.0.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-26.0.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-25.0.2 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-25.0.1 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-25.0.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-24.0.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-23.1.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-23.0.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-22.1.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-22.0.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-21.0.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-20.0.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-19.0.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-18.1.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-18.0.0 lib/google/ads/google_ads/lookup_util.rb
google-ads-googleads-17.0.0 lib/google/ads/google_ads/lookup_util.rb