Sha256: 62c408bc00839f50fee68161e01304ba49824cc7658e4092210e0d352562281a

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module SdbDal

class IndexDescription < DomainAttributeDescription
    include SdbFormatter
 attr_accessor :columns
  

  def self.crypto
    @@crypto||=Crypto.new
    @@crypto
  end
    
  def initialize(name,columns,is_encrypted=false)
    self.name=name
    self.columns=columns
    self.value_type =:string
    self.is_primary_key=false
    self.is_encrypted=is_encrypted
  end
  
  def format_index_entry(attribute_descriptions,attribute_values)
   result=""
      columns.each do |column|
        if column.respond_to?(:transform)
          result << column.transform(attribute_values[column.source_column] )
        else
          result << attribute_descriptions[column].format_for_sdb(attribute_values[column]).to_s
        end
        result << "&"
      end
      
      result
  end
  def format_for_sdb(value)
    #don't encrypt because the individual elements are encrypted
    return value
  end
  def keys_match?(h)
    return false unless h.length==columns.length
    columns.each do |c|
      return false unless h.has_key?(c)
    end
    return true
  end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sdb_dal-0.0.8 ./lib/sdb_dal/index_description.rb
sdb_dal-0.0.9 ./lib/sdb_dal/index_description.rb