Sha256: cc9ee071205208a71d9fb0c62172a0ac8098d2b17c762693b7f62d50a0ec2ee1

Contents?: true

Size: 341 Bytes

Versions: 2

Compression:

Stored size: 341 Bytes

Contents

# frozen_string_literal: true

module ActiveFields
  module Casters
    class IntegerCaster < BaseCaster
      def serialize(value)
        cast(value)
      end

      def deserialize(value)
        cast(value)
      end

      private

      def cast(value)
        BigDecimal(value, 0, exception: false)&.to_i
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_fields-1.1.0 lib/active_fields/casters/integer_caster.rb
active_fields-1.0.0 lib/active_fields/casters/integer_caster.rb