Class: MongoModel::Types::Integer
- Inherits:
-
Object
- Object
- Object
- MongoModel::Types::Integer
show all
- Defined in:
- lib/mongomodel/support/types/integer.rb
Instance Method Summary
collapse
Methods inherited from Object
#from_mongo, #to_mongo, #to_query
Instance Method Details
#boolean(value) ⇒ Object
16
17
18
|
# File 'lib/mongomodel/support/types/integer.rb', line 16
def boolean(value)
!value.zero?
end
|
#cast(value) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/mongomodel/support/types/integer.rb', line 4
def cast(value)
if value.nil?
nil
else
begin
Kernel::Integer(value)
rescue ArgumentError
Kernel::Float(value).to_i rescue nil
end
end
end
|