Sha256: 45733ad14766296e3cbd6720688a923ea60c164ead492fd3edb7607837835b5e

Contents?: true

Size: 562 Bytes

Versions: 7

Compression:

Stored size: 562 Bytes

Contents

# frozen_string_literal: true

module Acfs::Resource::Attributes
  # @api public
  #
  # Integer attribute type. Use it in your model as an attribute type:
  #
  # @example
  #   class User < Acfs::Resource
  #     attribute :name, :integer
  #   end
  #
  class Integer < Base
    # @api public
    #
    # Cast given object to integer.
    #
    # @param [Object] value Object to cast.
    # @return [Fixnum] Casted object as fixnum.
    #
    def cast_value(value)
      if value.blank?
        0
      else
        Integer(value)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
acfs-2.0.0 lib/acfs/resource/attributes/integer.rb
acfs-1.7.0 lib/acfs/resource/attributes/integer.rb
acfs-1.6.0 lib/acfs/resource/attributes/integer.rb
acfs-1.5.1 lib/acfs/resource/attributes/integer.rb
acfs-1.5.0 lib/acfs/resource/attributes/integer.rb
acfs-1.4.0 lib/acfs/resource/attributes/integer.rb
acfs-1.3.4 lib/acfs/resource/attributes/integer.rb