Sha256: 964e5d195386988cb774721fda448d9f62f05a5ed7ecb6745925d77d6e39c8e8

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

module Document
  
  # Store wrapper methods for document
  def get_data(doctype,type=Hash)
    Store.get_data(docname(doctype),type)
  end
  
  def get_value(doctype)
    Store.get_value(docname(doctype))
  end
  
  def put_data(doctype,data,append=false)
    Store.put_data(docname(doctype),data,append)
  end
  
  def put_value(doctype,data)
    Store.put_value(docname(doctype),data)
  end
  
  def delete_data(doctype,data)
    Store.delete_data(docname(doctype),data)
  end
  
  def flash_data(doctype)
    Store.flash_data(docname(doctype))
  end
  
  def flash_source_data(doctype, from_source)
    self.source_name=from_source
    docnamestr = docname('') + doctype
    Store.flash_data(docnamestr)
  end
  
  def rename(srcdoctype,dstdoctype)
    Store.rename(docname(srcdoctype),docname(dstdoctype))
  end
  
  # Generate the fully-qualified docname
  def docname(doctype)
    "#{self.class.class_prefix(self.class)}:#{self.app_id}:#{self.doc_suffix(doctype)}"
  end
  
  # Update count for a given document
  def update_count(doctype,count)
    name = docname(doctype)
    value = Store.db.get(name).to_i + count
    Store.db.set(name,value < 0 ? 0 : value) 
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rhoconnect-3.0.0.rc1 lib/rhoconnect/document.rb
rhoconnect-3.0.0.beta3 lib/rhoconnect/document.rb
rhoconnect-3.0.0.beta1 lib/rhoconnect/document.rb