Sha256: 4a9e5277ea4a334232d29893c530da30d85aed4761b0fc8864ac738ea4ef8362

Contents?: true

Size: 468 Bytes

Versions: 6

Compression:

Stored size: 468 Bytes

Contents

# frozen_string_literal: true

require 'set'

using SmartCore::Ext::BasicObjectAsObject

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

  type.define_caster do |value|
    begin
      ::Set.new(SmartCore::Types::Value::Array.cast(value))
    rescue ::ArgumentError, ::NoMethodError
      raise(SmartCore::Types::TypeCastingError, 'Non-castable to Set')
    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/set.rb
smart_types-0.7.1 lib/smart_core/types/value/set.rb
smart_types-0.7.0 lib/smart_core/types/value/set.rb
smart_types-0.6.0 lib/smart_core/types/value/set.rb
smart_types-0.4.0 lib/smart_core/types/value/set.rb
smart_types-0.3.0 lib/smart_core/types/value/set.rb