Sha256: f746a752da22c1e700ae00aca699de035e745ddf1750dc730771d6c8bcf10e16
Contents?: true
Size: 1.4 KB
Versions: 2
Compression:
Stored size: 1.4 KB
Contents
class Site < SiteManager attr_reader :id def initialize info if info.is_a? Integer @id = info else make_ivars info @id = insert_new end load_info end def make_ivars hash hash.each do |ivar, val| self.class.send :attr_accessor, ivar unless respond_to? ivar send "#{ivar}=", val end end # Add a task to the array of pending tasks in @tasks. # # ==== Attributes # # * +task+ - Hash that describes the task. Must contain the keys :rowid and :action. # # ==== Examples # # Adding a task to clone site 2 from site 1 # # s = Site.new 42 # t = {:rowid=>1, :src=>1, :site=>2, :action=>:clones} # s.add_task t def add_task task @tasks = [] unless @tasks @tasks << task end # Removes a task from list of pending tasks in @tasks # # ==== Attributes # # * +task+ - Hash that describes the task. Must contain the keys :rowid and :action. # # ==== Examples # # Removing a task to clone site 2 from site 1 # # s = Site.new 42 # t = {:rowid=>1, :src=>1, :site=>2, :action=>:clones} # s.clear_task t def clear_task task action = task[:action] id = task[:rowid] @@db.delete_action_by_id action, id end # Runs all tasks in the list of pending tasks in @tasks. Removes the task on sucess or BadTask. def run_all tasks = @tasks tasks.each do |t| self.send t[:action], t clear_task t end end class DuplicateAttr < RuntimeError end end
Version data entries
2 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kit-0.0.2 | ./site.rb |
kit-0.0.2 | site.rb |