Sha256: e0ba432f37748bdfb91d5f020457bc3585bcd0cfd518be5a6b1c2e1eff8ada21

Contents?: true

Size: 633 Bytes

Versions: 2

Compression:

Stored size: 633 Bytes

Contents

# frozen_string_literal: true

module Arstotzka
  # Concern with all the type cast methods to be used by {Wrapper}
  #
  # Usage of typecast is defined by the configuration of {Builder} by the usage of
  # option type
  module TypeCast
    extend ActiveSupport::Concern

    # converts a value to integer
    # @return [Integer]
    def to_integer(value)
      value.to_i if value.present?
    end

    # converts value to string
    # @return [String]
    def to_string(value)
      value.to_s
    end

    # converts value to float
    # @return [Float]
    def to_float(value)
      value.to_f if value.present?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arstotzka-1.0.3 lib/arstotzka/type_cast.rb
arstotzka-1.0.2 lib/arstotzka/type_cast.rb