class Spurious::Ruby::Awssdk::Strategy

Attributes

mapping[R]

Public Class Methods

new(set_all = false) click to toggle source
# File lib/spurious/ruby/awssdk/strategy.rb, line 8
def initialize(set_all = false)
  @mapping = {}
  return unless set_all

  dynamo
  sqs
  s3
end

Public Instance Methods

apply(config) click to toggle source
# File lib/spurious/ruby/awssdk/strategy.rb, line 17
def apply(config)
  mapping.each do |type, mappings|
    ports = config[type]
    Aws.config.update("#{mappings['identifier']}_port".to_sym => ports.first["HostPort"]) if mappings["port"]
    Aws.config.update("#{mappings['identifier']}_endpoint".to_sym => ports.first["Host"]) if mappings["ip"]
  end

  Aws.config.update(:use_ssl => false, :s3_force_path_style => true)
end
dynamo(port = true, ip = true) click to toggle source
# File lib/spurious/ruby/awssdk/strategy.rb, line 27
def dynamo(port = true, ip = true)
  mapping["spurious-dynamo"] = {
    "port"       => port,
    "ip"         => ip,
    "identifier" => "dynamo_db"
  }
end
s3(port = true, ip = true) click to toggle source
# File lib/spurious/ruby/awssdk/strategy.rb, line 35
def s3(port = true, ip = true)
  mapping["spurious-s3"] = {
    "port"       => port,
    "ip"         => ip,
    "identifier" => "s3"
  }
end
sqs(port = true, ip = true) click to toggle source
# File lib/spurious/ruby/awssdk/strategy.rb, line 43
def sqs(port = true, ip = true)
  mapping["spurious-sqs"] = {
    "port"       => port,
    "ip"         => ip,
    "identifier" => "sqs"
  }
end