Skip to content

Commit

Permalink
Syntax polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurnn committed Mar 7, 2014
1 parent b57da83 commit 5ad4c8d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Expand Up @@ -228,11 +228,11 @@ def deep_symbolize_keys; to_hash.deep_symbolize_keys end
def to_options!; self end

def select(*args, &block)
dup.tap { |hash| hash.select!(*args, &block)}
dup.tap { |hash| hash.select!(*args, &block) }
end

def reject(*args, &block)
dup.tap { |hash| hash.reject!(*args, &block)}
dup.tap { |hash| hash.reject!(*args, &block) }
end

# Convert to a regular hash with string keys.
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/ordered_hash.rb
Expand Up @@ -33,7 +33,7 @@ def select(*args, &block)
end

def reject(*args, &block)
dup.tap { |hash| hash.reject!(*args, &block)}
dup.tap { |hash| hash.reject!(*args, &block) }
end

def nested_under_indifferent_access
Expand Down
8 changes: 4 additions & 4 deletions activesupport/test/core_ext/hash_ext_test.rb
Expand Up @@ -481,30 +481,30 @@ def test_indifferent_deleting
end

def test_indifferent_select
hash = ActiveSupport::HashWithIndifferentAccess.new(@strings).select {|k,v| v == 1}
hash = ActiveSupport::HashWithIndifferentAccess.new(@strings).select { |_ ,v| v == 1 }

assert_equal({ 'a' => 1 }, hash)
assert_instance_of ActiveSupport::HashWithIndifferentAccess, hash
end

def test_indifferent_select_bang
indifferent_strings = ActiveSupport::HashWithIndifferentAccess.new(@strings)
indifferent_strings.select! {|k,v| v == 1}
indifferent_strings.select! { |_, v| v == 1 }

assert_equal({ 'a' => 1 }, indifferent_strings)
assert_instance_of ActiveSupport::HashWithIndifferentAccess, indifferent_strings
end

def test_indifferent_reject
hash = ActiveSupport::HashWithIndifferentAccess.new(@strings).reject {|k,v| v != 1}
hash = ActiveSupport::HashWithIndifferentAccess.new(@strings).reject { |_, v| v != 1 }

assert_equal({ 'a' => 1 }, hash)
assert_instance_of ActiveSupport::HashWithIndifferentAccess, hash
end

def test_indifferent_reject_bang
indifferent_strings = ActiveSupport::HashWithIndifferentAccess.new(@strings)
indifferent_strings.reject! {|k,v| v != 1}
indifferent_strings.reject! { |_, v| v != 1 }

assert_equal({ 'a' => 1 }, indifferent_strings)
assert_instance_of ActiveSupport::HashWithIndifferentAccess, indifferent_strings
Expand Down

0 comments on commit 5ad4c8d

Please sign in to comment.