Sha256: 760af9b0a2239739bd250f277ebae36139dfc5af367e1a134f4232171be98570

Contents?: true

Size: 638 Bytes

Versions: 9

Compression:

Stored size: 638 Bytes

Contents

module Render
  module Extensions
    class SymbolizableArray < Array
      class << self
        def new(array)
          array.inject(super()) do |accumulator, item|
            if item.is_a?(Array)
              accumulator << new(item)
            elsif item.is_a?(Hash)
              accumulator << DottableHash.new(item)
            else
              accumulator << item
            end
          end
        end
      end

      def recursively_symbolize_keys!
        each do |item|
          item.recursively_symbolize_keys! if item.respond_to?(:recursively_symbolize_keys!)
        end
        self
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
render-0.1.3 lib/render/extensions/symbolizable_array.rb
render-0.1.2 lib/render/extensions/symbolizable_array.rb
render-0.1.1 lib/render/extensions/symbolizable_array.rb
render-0.1.0 lib/render/extensions/symbolizable_array.rb
render-0.0.9 lib/render/extensions/symbolizable_array.rb
render-0.0.8 lib/render/extensions/symbolizable_array.rb
render-0.0.7 lib/render/extensions/symbolizable_array.rb
render-0.0.6 lib/render/extensions/symbolizable_array.rb
render-0.0.5 lib/render/extensions/symbolizable_array.rb