Class: SdbDal::IndexDescription

Inherits:
DomainAttributeDescription show all
Includes:
SdbFormatter
Defined in:
lib/sdb_dal/index_description.rb

Instance Attribute Summary collapse

Attributes inherited from DomainAttributeDescription

#is_collection, #is_encrypted, #is_primary_key, #name, #value_type

Instance Method Summary collapse

Methods included from SdbFormatter

#format_boolean, #format_date, #format_float, #format_integer, #format_reference_set, #format_string, #format_unsigned_integer, #parse_boolean, #parse_date, #parse_float, #parse_integer, #parse_reference_set, #parse_unsigned_integer, #zero_pad_float, #zero_pad_integer

Methods inherited from DomainAttributeDescription

crypto, #format_for_sdb_single, #is_clob, #parse_from_sdb, #parse_from_sdb_single

Constructor Details

#initialize(name, columns, is_encrypted = false) ⇒ IndexDescription

Returns a new instance of IndexDescription.



8
9
10
11
12
13
14
# File 'lib/sdb_dal/index_description.rb', line 8

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

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



5
6
7
# File 'lib/sdb_dal/index_description.rb', line 5

def columns
  @columns
end

Instance Method Details

#format_for_sdb(value) ⇒ Object



29
30
31
32
# File 'lib/sdb_dal/index_description.rb', line 29

def format_for_sdb(value)
  #don't encrypt because the individual elements are encrypted
  return value
end

#format_index_entry(attribute_descriptions, attribute_values) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sdb_dal/index_description.rb', line 16

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

#keys_match?(h) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
# File 'lib/sdb_dal/index_description.rb', line 33

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