Class: Spurious::Ruby::Awssdk::Strategy

Inherits:
Object
  • Object
show all
Defined in:
lib/spurious/ruby/awssdk/strategy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(set_all = false) ⇒ Strategy



10
11
12
13
14
15
16
17
# File 'lib/spurious/ruby/awssdk/strategy.rb', line 10

def initialize(set_all = false)
  @mapping = {}
  if set_all then
    dynamo
    sqs
    s3
  end
end

Instance Attribute Details

#mappingObject

Returns the value of attribute mapping.



8
9
10
# File 'lib/spurious/ruby/awssdk/strategy.rb', line 8

def mapping
  @mapping
end

Instance Method Details

#apply(config) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/spurious/ruby/awssdk/strategy.rb', line 43

def apply(config)
  mapping.each do |type, mappings|
    ports = config[type]
    AWS.config("#{mappings['identifier']}_port".to_sym => ports.first['HostPort']) if mappings['port']
    AWS.config("#{mappings['identifier']}_endpoint".to_sym => ports.first['Host']) if mappings['ip']
  end

  AWS.config(:use_ssl => false, :s3_force_path_style => true)

end

#dynamo(port = true, ip = true) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/spurious/ruby/awssdk/strategy.rb', line 19

def dynamo(port = true, ip = true)
  mapping['spurious-dynamo'] = {
    'port'       => port,
    'ip'         => ip,
    'identifier' => 'dynamo_db'
  }
end

#s3(port = true, ip = true) ⇒ Object



35
36
37
38
39
40
41
# 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) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/spurious/ruby/awssdk/strategy.rb', line 27

def sqs(port = true, ip = true)
  mapping['spurious-sqs'] = {
    'port'       => port,
    'ip'         => ip,
    'identifier' => 'sqs'
  }
end