Module: Aerosol::AWS
Overview
This module holds the connections for all AWS services used by the gem.
Instance Method Summary collapse
- #creds ⇒ Object
- #env_attr(*names) ⇒ Object
- #env_attrs ⇒ Object
- #reset_cache! ⇒ Object
- #service(name, klass) ⇒ Object
- #services ⇒ Object
Instance Method Details
#creds ⇒ Object
40 41 42 |
# File 'lib/aerosol/aws.rb', line 40 def creds Hash[env_attrs.map { |attr| [attr, public_send(attr)] }].reject { |k, v| v.nil? } end |
#env_attr(*names) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/aerosol/aws.rb', line 21 def env_attr(*names) names.each do |name| define_method name do instance_variable_get(:"@#{name}") || ENV[name.to_s.upcase] end define_method :"#{name}=" do |val| reset_cache! instance_variable_set(:"@#{name}", val) end env_attrs << name end end |
#env_attrs ⇒ Object
36 37 38 |
# File 'lib/aerosol/aws.rb', line 36 def env_attrs @env_attrs ||= [] end |
#reset_cache! ⇒ Object
44 45 46 |
# File 'lib/aerosol/aws.rb', line 44 def reset_cache! services.each { |service| instance_variable_set(:"@#{service}", nil) } end |
#service(name, klass) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/aerosol/aws.rb', line 5 def service(name, klass) define_method name do if val = instance_variable_get(:"@#{name}") val else instance = klass.new(creds) instance_variable_set(:"@#{name}", instance) end end services << name end |
#services ⇒ Object
17 18 19 |
# File 'lib/aerosol/aws.rb', line 17 def services @services ||= [] end |