Sha256: af8b6ca1996eeb68c558f421b0d9113033afa36ab9cbd83e9f1ee1b906b84d12

Contents?: true

Size: 438 Bytes

Versions: 6

Compression:

Stored size: 438 Bytes

Contents

# frozen_string_literal: true

using SmartCore::Ext::BasicObjectAsObject

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

  type.define_caster do |value|
    begin
      value.to_sym
    rescue ::NoMethodError, ::ArgumentError
      raise(SmartCore::Types::TypeCastingError, 'Non-castable to Symbol')
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
smart_types-0.8.0 lib/smart_core/types/value/symbol.rb
smart_types-0.7.1 lib/smart_core/types/value/symbol.rb
smart_types-0.7.0 lib/smart_core/types/value/symbol.rb
smart_types-0.6.0 lib/smart_core/types/value/symbol.rb
smart_types-0.4.0 lib/smart_core/types/value/symbol.rb
smart_types-0.3.0 lib/smart_core/types/value/symbol.rb