Sha256: fb553cbfdbc8cb136bda1086819358c076a2f80c0fde99140372d4bb655196a5

Contents?: true

Size: 889 Bytes

Versions: 14

Compression:

Stored size: 889 Bytes

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2019 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

require 'active_support/core_ext/string/inflections'
require_relative 'cloud_resource_client'

module GoodData
  module CloudResources
    class CloudResourceFactory
      class << self
        def create(type, data = {}, opts = {})
          clients = CloudResourceClient.descendants.select { |c| c.respond_to?("accept?") && c.send("accept?", type) }
          raise "DataSource does not support type \"#{type}\"" if clients.empty?

          res = clients[0].new(data)
          opts.each do |key, value|
            method = "#{key}="
            res.send(method, value) if res.respond_to?(method)
          end
          res
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
gooddata-2.1.15-java lib/gooddata/cloud_resources/cloud_resouce_factory.rb
gooddata-2.1.15 lib/gooddata/cloud_resources/cloud_resouce_factory.rb
gooddata-2.1.14-java lib/gooddata/cloud_resources/cloud_resouce_factory.rb
gooddata-2.1.14 lib/gooddata/cloud_resources/cloud_resouce_factory.rb
gooddata-2.1.13-java lib/gooddata/cloud_resources/cloud_resouce_factory.rb
gooddata-2.1.13 lib/gooddata/cloud_resources/cloud_resouce_factory.rb
gooddata-2.1.12-java lib/gooddata/cloud_resources/cloud_resouce_factory.rb
gooddata-2.1.12 lib/gooddata/cloud_resources/cloud_resouce_factory.rb
gooddata-2.1.11-java lib/gooddata/cloud_resources/cloud_resouce_factory.rb
gooddata-2.1.11 lib/gooddata/cloud_resources/cloud_resouce_factory.rb
gooddata-2.1.10-java lib/gooddata/cloud_resources/cloud_resouce_factory.rb
gooddata-2.1.10 lib/gooddata/cloud_resources/cloud_resouce_factory.rb
gooddata-2.1.9-java lib/gooddata/cloud_resources/cloud_resouce_factory.rb
gooddata-2.1.9 lib/gooddata/cloud_resources/cloud_resouce_factory.rb