Sha256: 0b8d805d0529c414f21142af81425fca699d0d31bbdf0572736be532384234ba

Contents?: true

Size: 429 Bytes

Versions: 5

Compression:

Stored size: 429 Bytes

Contents

class IntegerField < Field
  def numeric?
    true
  end
  
  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
  
  def untypecast(value, record)
    value.to_i
  end
  
  def from_json(value, record)
    value.to_i
  end
end

Field::TYPES['integer'] = IntegerField

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yodel-0.0.7 lib/yodel/models/core/fields/integer_field.rb
yodel-0.0.4 lib/yodel/models/core/fields/integer_field.rb
yodel-0.0.3 lib/yodel/models/core/fields/integer_field.rb
yodel-0.0.2 lib/yodel/models/core/fields/integer_field.rb
yodel-0.0.1 lib/yodel/models/core/fields/integer_field.rb