class Akashi::Base

Public Class Methods

all() click to toggle source
# File lib/akashi/base.rb, line 15
def all
  collection.map { |object| new(object.id) }
end
base_class() click to toggle source
# File lib/akashi/base.rb, line 45
def base_class
  @base_class ||= "::AWS::#{service_class}::#{object_class}".constantize
end
collection() click to toggle source
# File lib/akashi/base.rb, line 41
def collection
  Akashi::Aws.send(service_class.underscore).send(object_class.underscore.pluralize)
end
find(id) click to toggle source
# File lib/akashi/base.rb, line 25
def find(id)
  instances = where(id: id)
  fail "#{id} does not exist" if instances.empty?
  instances.first
end
find_by(conditions = {}) click to toggle source
# File lib/akashi/base.rb, line 31
def find_by(conditions = {})
  instances = where(conditions)
  fail "#{conditions} does not exist" if instances.empty?
  instances.first
end
new(id) click to toggle source
# File lib/akashi/base.rb, line 10
def initialize(id)
  @object = self.class.base_class.new(id)
end
object_class() click to toggle source
# File lib/akashi/base.rb, line 37
def object_class
  @object_class ||= self.to_s.demodulize
end
where(conditions = {}) click to toggle source
# File lib/akashi/base.rb, line 19
def where(conditions = {})
  all.select do |instance|
    conditions.all? { |k, v| instance.send(k.intern) == v }
  end
end