Class: IntegerField

Inherits:
Field
  • Object
show all
Defined in:
lib/yodel/models/core/fields/integer_field.rb

Constant Summary

Constants inherited from Field

Field::TYPES

Instance Attribute Summary

Attributes inherited from Field

#name, #options

Instance Method Summary collapse

Methods inherited from Field

#default_input_type, #display?, field_from_type, from_options, #include_in_search_keywords?, #index?, #inherited?, #initialize, #method_missing, #required?, #searchable?, #strip_nil?, #to_json, #to_str, #typecast, #unique?, #validate

Constructor Details

This class inherits a constructor from Field

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Field

Instance Method Details

#from_json(value, record) ⇒ Object



20
21
22
# File 'lib/yodel/models/core/fields/integer_field.rb', line 20

def from_json(value, record)
  value.to_i
end

#json_action(action, value, record) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/yodel/models/core/fields/integer_field.rb', line 6

def json_action(action, value, record)
  case action
  when 'set'
    record.set_raw(name, value.to_i)
  when 'increment'
    record.increment!(name, value.to_i)
  end
  record.changed!(name)
end

#numeric?Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/yodel/models/core/fields/integer_field.rb', line 2

def numeric?
  true
end

#untypecast(value, record) ⇒ Object



16
17
18
# File 'lib/yodel/models/core/fields/integer_field.rb', line 16

def untypecast(value, record)
  value.to_i
end