Class: Stackster::Entry
- Inherits:
-
Object
- Object
- Stackster::Entry
- Defined in:
- lib/stackster/entry.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
- #delete_attributes ⇒ Object
-
#initialize(args) ⇒ Entry
constructor
A new instance of Entry.
- #save ⇒ Object
- #set_attributes(a) ⇒ Object
Constructor Details
#initialize(args) ⇒ Entry
Returns a new instance of Entry.
7 8 9 10 11 12 13 14 |
# File 'lib/stackster/entry.rb', line 7 def initialize(args) @domain = 'stacks' @config = args[:config] @logger = @config.logger @custom_attributes = {} self.name = region_specific_name args[:name] create_domain end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/stackster/entry.rb', line 5 def name @name end |
Class Method Details
Instance Method Details
#attributes ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/stackster/entry.rb', line 22 def attributes u = {} attrs = sdb_connect.select "select * from stacks where itemName() = '#{name}'" if attrs.has_key? name u.merge! Hash[attrs[name].map { |k,v| [k, v.first] }] end u.merge @custom_attributes end |
#delete_attributes ⇒ Object
53 54 55 56 |
# File 'lib/stackster/entry.rb', line 53 def delete_attributes sdb_connect.delete('stacks', name) @logger.info "Delete from SimpleDB successful." end |
#save ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/stackster/entry.rb', line 37 def save set_default_attributes current_attributes = attributes current_attributes.each_pair do |key,value| @logger.debug "Setting attribute #{key}=#{value}" end sdb_connect.put_attributes('stacks', name, current_attributes, :replace => current_attributes.keys ) @logger.debug "Save to SimpleDB successful." end |
#set_attributes(a) ⇒ Object
33 34 35 |
# File 'lib/stackster/entry.rb', line 33 def set_attributes(a) a.each { |attribute| set_attribute(attribute) } end |