Class: Acfs::Resource::Attributes::Integer

Inherits:
Base
  • Object
show all
Defined in:
lib/acfs/resource/attributes/integer.rb

Overview

Integer attribute type. Use it in your model as an attribute type:

Examples:

class User < Acfs::Resource
  attribute :name, :integer
end

Instance Attribute Summary

Attributes inherited from Base

#default

Instance Method Summary collapse

Methods inherited from Base

#cast, #default_value, #initialize

Constructor Details

This class inherits a constructor from Acfs::Resource::Attributes::Base

Instance Method Details

#cast_value(value) ⇒ Fixnum

Cast given object to integer.

Parameters:

  • value (Object)

    Object to cast.

Returns:

  • (Fixnum)

    Casted object as fixnum.



21
22
23
24
25
26
27
# File 'lib/acfs/resource/attributes/integer.rb', line 21

def cast_value(value)
  if value.blank?
    0
  else
    Integer(value)
  end
end