Module: Miasma
- Defined in:
- lib/miasma.rb,
lib/miasma/error.rb,
lib/miasma/types.rb,
lib/miasma/utils.rb,
lib/miasma/models.rb,
lib/miasma/version.rb,
lib/miasma/types/api.rb,
lib/miasma/types/data.rb,
lib/miasma/utils/lazy.rb,
lib/miasma/contrib/aws.rb,
lib/miasma/types/model.rb,
lib/miasma/utils/smash.rb,
lib/miasma/models/compute.rb,
lib/miasma/models/storage.rb,
lib/miasma/utils/immutable.rb,
lib/miasma/types/collection.rb,
lib/miasma/types/thin_model.rb,
lib/miasma/contrib/rackspace.rb,
lib/miasma/models/auto_scale.rb,
lib/miasma/utils/memoization.rb,
lib/miasma/contrib/open_stack.rb,
lib/miasma/contrib/aws/compute.rb,
lib/miasma/contrib/aws/storage.rb,
lib/miasma/models/storage/file.rb,
lib/miasma/models/load_balancer.rb,
lib/miasma/models/orchestration.rb,
lib/miasma/models/storage/files.rb,
lib/miasma/utils/animal_strings.rb,
lib/miasma/models/compute/server.rb,
lib/miasma/models/storage/bucket.rb,
lib/miasma/contrib/aws/auto_scale.rb,
lib/miasma/models/compute/servers.rb,
lib/miasma/models/storage/buckets.rb,
lib/miasma/models/auto_scale/group.rb,
lib/miasma/models/auto_scale/groups.rb,
lib/miasma/contrib/aws/load_balancer.rb,
lib/miasma/contrib/aws/orchestration.rb,
lib/miasma/contrib/rackspace/compute.rb,
lib/miasma/contrib/open_stack/compute.rb,
lib/miasma/models/orchestration/event.rb,
lib/miasma/models/orchestration/stack.rb,
lib/miasma/models/orchestration/events.rb,
lib/miasma/models/orchestration/stacks.rb,
lib/miasma/contrib/rackspace/auto_scale.rb,
lib/miasma/models/load_balancer/balancer.rb,
lib/miasma/models/orchestration/resource.rb,
lib/miasma/models/load_balancer/balancers.rb,
lib/miasma/models/orchestration/resources.rb,
lib/miasma/contrib/rackspace/load_balancer.rb,
lib/miasma/contrib/rackspace/orchestration.rb,
lib/miasma/contrib/open_stack/orchestration.rb
Defined Under Namespace
Modules: Contrib, Models, Types, Utils Classes: Error
Constant Summary collapse
- VERSION =
current library version
Gem::Version.new('0.2.2')
Class Method Summary collapse
-
.api(args = {}) ⇒ Object
Generate and API connection.
Class Method Details
.api(args = {}) ⇒ Object
Generate and API connection
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/miasma.rb', line 21 def self.api(args={}) args = Utils::Smash.new(args) [:type, :provider, :credentials].each do |key| unless(args[key]) raise ArgumentError.new "Missing required api argument `#{key.inspect}`!" end end args[:type] = Utils.camel(args[:type].to_s).to_sym args[:provider] = Utils.camel(args[:provider].to_s).to_sym begin require "miasma/contrib/#{Utils.snake(args[:provider])}" rescue LoadError # just ignore end base_klass = Models.const_get(args[:type]) begin if(base_klass) api_klass = base_klass.const_get(args[:provider]) if(api_klass) api_klass.new(args[:credentials].to_smash) else raise Error.new "Failed to locate #{args[:type]} API for #{args[:provider].inspect}" end else raise Error.new "Failed to locate request API type #{args[:type].inspect}" end rescue NameError raise Error.new "Failed to locate request API type #{args[:type].inspect}" end end |