Sha256: 545f1cbc35b22db6c97f251cc77df6d3b1f29bc8947eb722bc164905b1891cfc

Contents?: true

Size: 1.77 KB

Versions: 16

Compression:

Stored size: 1.77 KB

Contents

require 'aws-sdk-core'

module Aws
  module Resources

    autoload :Batch, 'aws-sdk-resources/batch'
    autoload :Builder, 'aws-sdk-resources/builder'
    autoload :BuilderSources, 'aws-sdk-resources/builder_sources'
    autoload :Collection, 'aws-sdk-resources/collection'
    autoload :Definition, 'aws-sdk-resources/definition'
    autoload :Documenter, 'aws-sdk-resources/documenter'
    autoload :Errors, 'aws-sdk-resources/errors'
    autoload :Operations, 'aws-sdk-resources/operations'
    autoload :OperationMethods, 'aws-sdk-resources/operation_methods'
    autoload :Options, 'aws-sdk-resources/options'
    autoload :Request, 'aws-sdk-resources/request'
    autoload :RequestParams, 'aws-sdk-resources/request_params'
    autoload :Resource, 'aws-sdk-resources/resource'
    autoload :Source, 'aws-sdk-resources/source'
    autoload :Validator, 'aws-sdk-resources/validator'

  end

  class << self

    private

    def define_resource_classes(svc_module, definition)
      build_definition(definition).apply(svc_module)
    end

    def build_definition(definition)
      case definition
      when nil then Resources::Definition.new({})
      when Resources::Definition then definition
      when Hash then Resources::Definition.new(definition)
      when String, Pathname then Resources::Definition.new(Aws.load_json(definition), source_path: definition.to_s)
      else raise ArgumentError, "invalid resource definition #{definition}"
      end
    end

    def load_resource_customizations(svc_name)
      require "aws-sdk-resources/services/#{svc_name.downcase}"
    rescue LoadError
      # no customizations
    end

  end

  service_added do |svc_name, svc_module, options|
    define_resource_classes(svc_module, options[:resources])
    load_resource_customizations(svc_name)
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aws-sdk-resources-2.0.21.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.20.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.19.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.18.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.17.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.16.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.15.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.14.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.13.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.12.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.11.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.10.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.9.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.8.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.7.pre lib/aws-sdk-resources.rb
aws-sdk-resources-2.0.6.pre lib/aws-sdk-resources.rb