Sha256: 71fa4ea78736cd53186e87b0660ea36445d4cb9740a363bc933b21a473eca4fd

Contents?: true

Size: 533 Bytes

Versions: 8

Compression:

Stored size: 533 Bytes

Contents

Kernel.class_eval do
  def swallow_nil
    yield
  rescue NoMethodError
    nil
  end
end

Array.class_eval do
  def arranged
    arranged = ActiveSupport::OrderedHash.new
    insertion_points = [arranged]
    depth = 0
    each do |node|
      insertion_points.push insertion_points.last.values.last if node.depth > depth
      (depth - node.depth).times { insertion_points.pop } if node.depth < depth
      insertion_points.last.merge! node => ActiveSupport::OrderedHash.new
      depth = node.depth
    end
    arranged
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
puffer_pages-0.1.1 lib/puffer_pages/extensions/core.rb
puffer_pages-0.1.0 lib/puffer_pages/extensions/core.rb
puffer_pages-0.0.19 lib/puffer_pages/extensions/core.rb
puffer_pages-0.0.18 lib/puffer_pages/extensions/core.rb
puffer_pages-0.0.17 lib/puffer_pages/extensions/core.rb
puffer_pages-0.0.16 lib/puffer_pages/extensions/core.rb
puffer_pages-0.0.15 lib/puffer_pages/extensions/core.rb
puffer_pages-0.0.14 lib/puffer_pages/extensions/core.rb