Module: Mongoid::Extensions::Integer::Conversions

Included in:
Integer
Defined in:
lib/mongoid/extensions/integer/conversions.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#get(value) ⇒ Object



14
15
16
# File 'lib/mongoid/extensions/integer/conversions.rb', line 14

def get(value)
  value
end

#set(value) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/mongoid/extensions/integer/conversions.rb', line 6

def set(value)
  return nil if value.blank?
  begin
    value.to_s =~ /\./ ? Float(value) : Integer(value)
  rescue
    value
  end
end