1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Remove to_hash helper

This commit is contained in:
Norman Clarke 2012-05-29 17:12:07 -03:00
parent 4a8403982f
commit 7edc909c4e
3 changed files with 1 additions and 20 deletions

View file

@ -201,7 +201,7 @@ RUBY
def attributes(class_id, obj_ref, *attributes_hashes)
attributes = class_id
attributes_hashes.each do |old|
self.class.merge_attrs(attributes, to_hash(old.map {|k, v| [k.to_s, v]}))
self.class.merge_attrs(attributes, Hash[old.map {|k, v| [k.to_s, v]}])
end
self.class.merge_attrs(attributes, parse_object_ref(obj_ref)) if obj_ref
Compiler.build_attributes(

View file

@ -27,17 +27,6 @@ module Haml
File.expand_path("../../../#{file}", __FILE__)
end
# Converts an array of `[key, value]` pairs to a hash.
#
# @example
# to_hash([[:foo, "bar"], [:baz, "bang"]])
# #=> {:foo => "bar", :baz => "bang"}
# @param arr [Array<(Object, Object)>] An array of pairs
# @return [Hash] A hash
def to_hash(arr)
Hash[arr.compact]
end
# Computes the powerset of the given array.
# This is the set of all subsets of the array.
#

View file

@ -20,14 +20,6 @@ class UtilTest < MiniTest::Unit::TestCase
assert(File.exist?(scope("Rakefile")))
end
def test_to_hash
assert_equal({
:foo => 1,
:bar => 2,
:baz => 3
}, to_hash([[:foo, 1], [:bar, 2], [:baz, 3]]))
end
def test_powerset
return unless Set[Set[]] == Set[Set[]] # There's a bug in Ruby 1.8.6 that breaks nested set equality
assert_equal([[].to_set].to_set,