Sha256: 5dca3082951a325ad87d708c0879d4d06f5bcde0e6c9ad79e1c1ca146509bf71
Contents?: true
Size: 1.39 KB
Versions: 3
Compression:
Stored size: 1.39 KB
Contents
class Bit < Kit 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
kit-0.0.5 | lib/kit/bit.rb |
kit-0.0.4 | lib/kit/bit.rb |
kit-0.0.3 | lib/kit/bit.rb |