Sha256: cce2413ff44fa11d977dfc2e4ca17b245b12dc28927312acaf9d23d81cc08613

Contents?: true

Size: 620 Bytes

Versions: 2

Compression:

Stored size: 620 Bytes

Contents

module Assertion

  # The collection of pure functions for converting arrays
  #
  # @api private
  #
  module List

    extend ::Transproc::Registry

    # Converts the nested array of strings and symbols into the flat
    # array of unique symbols
    #
    # @example
    #   fn = List[:symbolize]
    #   source = [:foo, ["foo", "bar"], :bar, "baz"]
    #   fn[source]
    #   # => [:foo, :bar, :baz]
    #
    # @param [Array<String, Symbol, Array>] array
    #
    # @return [Array<Symbol>]
    #
    def symbolize(array)
      array.flatten.map(&:to_sym).uniq
    end

  end # module List

end # module Assertion

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
assertion-0.1.0 lib/assertion/transprocs/list.rb
assertion-0.0.1 lib/assertion/transprocs/list.rb