Module: Aerosol::AWSModel

Included in:
AutoScaling, Instance, LaunchConfiguration, LaunchTemplate
Defined in:
lib/aerosol/aws_model.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



2
3
4
5
6
7
8
9
# File 'lib/aerosol/aws_model.rb', line 2

def self.included(base)
  base.instance_eval do
    include Dockly::Util::DSL
    extend ClassMethods

    attr_accessor :from_aws
  end
end

Instance Method Details

#createObject



24
25
26
27
# File 'lib/aerosol/aws_model.rb', line 24

def create
  raise '#create! must be defined to use #create' unless respond_to?(:create!)
  create! unless exists?
end

#default_identifierObject



20
21
22
# File 'lib/aerosol/aws_model.rb', line 20

def default_identifier
  "#{namespaced_name}-#{Aerosol::Util.git_sha}"
end

#destroyObject



29
30
31
32
# File 'lib/aerosol/aws_model.rb', line 29

def destroy
  raise '#destroy! must be defined to use #destroy' unless respond_to?(:destroy!)
  destroy! if exists?
end

#exists?Boolean

Returns:

  • (Boolean)


34
35
36
37
# File 'lib/aerosol/aws_model.rb', line 34

def exists?
  primary_value = send(self.class.primary_key)
  self.class.exists?(primary_value)
end

#initialize(hash = {}, &block) ⇒ Object



11
12
13
14
# File 'lib/aerosol/aws_model.rb', line 11

def initialize(hash={}, &block)
  self.from_aws = false
  super
end

#namespaced_nameObject



16
17
18
# File 'lib/aerosol/aws_model.rb', line 16

def namespaced_name
  Aerosol.namespace ? "#{Aerosol.namespace}-#{name}" : name.to_s
end