Sha256: fba9213c40590e9b78387a85e6df994885afb3b54dadb7a3c8ff6e13f01bfc9e

Contents?: true

Size: 715 Bytes

Versions: 1

Compression:

Stored size: 715 Bytes

Contents

module Virtus
  class Attribute

    # Example usage:
    #
    #   class Post
    #     include Virtus
    #
    #     attribute :read_count, Integer
    #   end
    #
    #   Post.new(:read_count => 100)
    #
    #   # typecasting from a string
    #   Post.new(:read_count => '100')
    #
    #   # typecasting from an object that implements #to_i
    #   Post.new(:read_count => 100.0)
    #
    class Integer < Numeric
      primitive ::Integer

      # @see Virtus::Typecast::Numeric.to_i
      #
      # @return [Integer]
      #
      # @api private
      def typecast_to_primitive(value)
        Typecast::Numeric.to_i(value)
      end

    end # class Integer
  end # class Attribute
end # module Virtus

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
virtus-0.0.5 lib/virtus/attribute/integer.rb