Class: Gapic::Model::Mixins

Inherits:
Object
  • Object
show all
Defined in:
lib/gapic/model/mixins.rb

Overview

Aggregated information about the mixin services that should be referenced from their gems in the generated client libraries

Defined Under Namespace

Classes: Mixin

Constant Summary collapse

LRO_SERVICE =

LRO might be specified in the mixins but it is not generated as a mixin

"google.longrunning.Operations"
LOCATIONS_SERVICE =

Locations and Iam are generated as mixins

"google.cloud.location.Locations"
IAM_SERVICE =
"google.iam.v1.IAMPolicy"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_services, service_config) ⇒ Mixins

Returns a new instance of Mixins.

Parameters:

  • api_services (Enumerable<String>)

    List of services from the Api model

  • service_config (Google::Api::Service)

    The service config



39
40
41
42
# File 'lib/gapic/model/mixins.rb', line 39

def initialize api_services, service_config
  @api_services = api_services
  @service_config = service_config
end

Instance Attribute Details

#api_servicesEnumerable<String>

Returns List of services from the Api model.

Returns:

  • (Enumerable<String>)

    List of services from the Api model



32
33
34
# File 'lib/gapic/model/mixins.rb', line 32

def api_services
  @api_services
end

Instance Method Details

#dependenciesHash<String, String>

Returns Aggregated dependencies for the mix-in services.

Returns:

  • (Hash<String, String>)

    Aggregated dependencies for the mix-in services



65
66
67
# File 'lib/gapic/model/mixins.rb', line 65

def dependencies
  @dependencies ||= mixins.reduce({}) { |deps, mixin| deps.merge mixin.dependency }
end

#mixin_servicesEnumerable<String>

Returns Full proto names of the mix-in services.

Returns:

  • (Enumerable<String>)

    Full proto names of the mix-in services



57
58
59
60
61
# File 'lib/gapic/model/mixins.rb', line 57

def mixin_services
  @mixin_services ||= services_in_config.select do |service|
    service != LRO_SERVICE && !@api_services.include?(service)
  end
end

#mixinsEnumerable<Mixin>

Returns List of Mixin objects, providing the information that is needed to add the mixin service references to the generated library.

Returns:

  • (Enumerable<Mixin>)

    List of Mixin objects, providing the information that is needed to add the mixin service references to the generated library



52
53
54
# File 'lib/gapic/model/mixins.rb', line 52

def mixins
  @mixins ||= mixin_services.map { |service| create_mixin(service) }
end

#mixins?Boolean

Returns Whether there are any mix-in services.

Returns:

  • (Boolean)

    Whether there are any mix-in services



45
46
47
# File 'lib/gapic/model/mixins.rb', line 45

def mixins?
  mixin_services.any?
end