Class: CassandraModel::IntegerType

Inherits:
Object
  • Object
show all
Defined in:
lib/cassandra-model/types.rb

Class Method Summary collapse

Class Method Details

.dump(v) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cassandra-model/types.rb', line 18

def self.dump(v)
  ret = nil
  if !v.blank?
    case v
    when String
      if v.size == 8
        ret = Cassandra::Long.new(v)
      else
        ret = v.to_i
      end
    when Cassandra::Long
      ret =v
    when ::Integer
      ret = Cassandra::Long.new(v)
    end
  end
  ret
end

.load(v) ⇒ Object



37
38
39
# File 'lib/cassandra-model/types.rb', line 37

def self.load(v)
  v && v.to_i
end