Sha256: c33caca1f78727bd103a0a6bd7b3f4ac8c5428e0b9c1116c08284dfb2563387a

Contents?: true

Size: 321 Bytes

Versions: 7

Compression:

Stored size: 321 Bytes

Contents

# frozen_string_literal: true

# @api public
# @since 0.1.0
SmartCore::Types::Value.define_type(:Integer) do |type|
  type.define_checker do |value|
    value.is_a?(::Integer)
  end

  type.define_caster do |value|
    begin
      Integer(value)
    rescue ::TypeError, ::ArgumentError
      value.to_i
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
smart_types-0.1.0.alpha6 lib/smart_core/types/value/integer.rb
smart_types-0.1.0.alpha5 lib/smart_core/types/value/integer.rb
smart_types-0.1.0.alpha4 lib/smart_core/types/value/integer.rb
smart_types-0.1.0.alpha3 lib/smart_core/types/value/integer.rb
smart_types-0.1.0.alpha2 lib/smart_core/types/value/integer.rb
smart_types-0.1.0.alpha lib/smart_core/types/value/integer.rb
smart_types-0.0.0 lib/smart_core/types/value/integer.rb