Sha256: 4c77b99b326c3a4a7d9104766eb91ca130da9fa1b911c27bedbe3a855109a8b7
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
require 'stackster/entry/entry_lister' module Stackster class Entry attr_accessor :name, :attributes def initialize(args) @domain = 'stacks' @config = args[:config] 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 attributes.each_pair do |k,v| sdb_connect.put_attributes('stacks', name, { k => v }, { :replace => k }) end end def delete_attributes sdb_connect.delete('stacks', name) end private 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stackster-0.2.1 | lib/stackster/entry.rb |