Sha256: 5a30018e93b457312d470459010c823c7f9f993e6ac7470013185bae5308c92e
Contents?: true
Size: 1.72 KB
Versions: 2
Compression:
Stored size: 1.72 KB
Contents
require 'stackster/entry/entry_lister' module Stackster class Entry attr_accessor :name, :attributes def initialize(args) @domain = 'stacks' @config = args[:config] @logger = @config.logger self.name = region_specific_name args[:name] create_domain get_attributes end def self.find(args) entry = Entry.new :name => args[:name], :config => args[:config] entry end def set_attributes(a) a.each { |attribute| set_attribute(attribute) } end def save set_name_attribute attributes.each_pair do |key,value| @logger.debug "Setting attribute #{key}=#{value}" end sdb_connect.put_attributes('stacks', name, attributes, :replace => attributes.keys ) @logger.debug "Save to SimpleDB successful." end def delete_attributes sdb_connect.delete('stacks', name) @logger.info "Delete from SimpleDB successful." end private def set_name_attribute attributes.merge!('Name' => name) end def get_attributes u = {} attrs = sdb_connect.select "select * from stacks where itemName() = '#{name}'" if attrs[name] attrs[name].each_pair { |k, v| u[k] = v.first } end self.attributes = u end def region_specific_name(name) "#{name}-#{@config.region}" end def create_domain sdb_connect.create_domain @domain end def set_attribute(attribute) self.attributes = attributes.merge(attribute) end def sdb_connect @sdb_connect ||= AWS::SimpleDB.new :config => @config end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stackster-0.2.9 | lib/stackster/entry.rb |
stackster-0.2.8 | lib/stackster/entry.rb |