Sha256: d58c6f588ab2b03f92a47b7403581548fcd7e575b0cfdfc1abd327eef97f60c4

Contents?: true

Size: 533 Bytes

Versions: 35

Compression:

Stored size: 533 Bytes

Contents

# Responsible for decorating a collection which responds to `to_a` which will
# stringify all of the elements.
#
# Example
#
#     ArrayStringifier.new({a: 1, b: 2}).to_a # => [["a", "1"], ["b", "2"]]
#
class ArrayStringifier < SimpleDelegator
  alias_method :collection, :__getobj__

  def to_a
    stringify_items(collection.to_a)
  end

  private

  def stringify_items(collection)
    collection.map do |item|
      if item.respond_to?(:map)
        stringify_items(item)
      else
        item.to_s
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
renalware-core-2.0.16 lib/array_stringifier.rb
renalware-core-2.0.15 lib/array_stringifier.rb
renalware-core-2.0.14 lib/array_stringifier.rb
renalware-core-2.0.13 lib/array_stringifier.rb
renalware-core-2.0.12 lib/array_stringifier.rb
renalware-core-2.0.11 lib/array_stringifier.rb
renalware-core-2.0.9 lib/array_stringifier.rb
renalware-core-2.0.8 lib/array_stringifier.rb
renalware-core-2.0.7 lib/array_stringifier.rb
renalware-core-2.0.5 lib/array_stringifier.rb
renalware-core-2.0.4 lib/array_stringifier.rb
renalware-core-2.0.3 lib/array_stringifier.rb
renalware-core-2.0.2 lib/array_stringifier.rb
renalware-core-2.0.1 lib/array_stringifier.rb
renalware-core-2.0.0 lib/array_stringifier.rb
renalware-core-2.0.0.pre.rc13 lib/array_stringifier.rb
renalware-core-2.0.0.pre.rc11 lib/array_stringifier.rb
renalware-core-2.0.0.pre.rc10 lib/array_stringifier.rb
renalware-core-2.0.0.pre.rc9 lib/array_stringifier.rb
renalware-core-2.0.0.pre.rc8 lib/array_stringifier.rb