Class: ActiveRecord::Embedded::Field::Integer

Inherits:
ActiveRecord::Embedded::Field show all
Defined in:
lib/active_record/embedded/field/integer.rb

Overview

Store whole numbers in the database. JSON has no distinction between integers and floats, but since Ruby does, this class ensures that the field can always be used as the “right” type.

Constant Summary

Constants inherited from ActiveRecord::Embedded::Field

PREFIX

Instance Attribute Summary

Attributes inherited from ActiveRecord::Embedded::Field

#default, #name

Instance Method Summary collapse

Methods inherited from ActiveRecord::Embedded::Field

#coerce, #default?, #default_method_name, find, #initialize, types

Constructor Details

This class inherits a constructor from ActiveRecord::Embedded::Field

Instance Method Details

#cast(value) ⇒ Object


11
12
13
# File 'lib/active_record/embedded/field/integer.rb', line 11

def cast(value)
  value.to_i
end