Sha256: 4f11513df17e63036e521a5cee32e7d691aee4758b19834e16fb5770e39e5493

Contents?: true

Size: 463 Bytes

Versions: 6

Compression:

Stored size: 463 Bytes

Contents

require 'parameters/types/array'

require 'set'

module Parameters
  module Types
    class Set < Array

      #
      # Coerces a value into a Set.
      #
      # @param [#to_set, ::Object] value
      #   The value to coerce.
      #
      # @return [::Set]
      #   The coerced Set.
      #
      def self.coerce(value)
        if value.respond_to?(:to_set)
          value.to_set
        else
          ::Set[value]
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
parameters-0.4.4 lib/parameters/types/set.rb
parameters-0.4.3 lib/parameters/types/set.rb
parameters-0.4.2 lib/parameters/types/set.rb
parameters-0.4.0 lib/parameters/types/set.rb
parameters-0.3.1 lib/parameters/types/set.rb
parameters-0.3.0 lib/parameters/types/set.rb