Skip to content

Commit 807a147

Browse files
committed
Removing redundant except method
1 parent 4aa27d1 commit 807a147

File tree

4 files changed

+0
-54
lines changed

4 files changed

+0
-54
lines changed

lib/bitbucket_rest_api/core_ext/array.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
class Array # :nodoc:
22

3-
def except(*keys) # :nodoc:
4-
self.dup.except!(*keys)
5-
end unless method_defined?(:except)
6-
7-
def except!(*items) # :nodoc:
8-
self.reject! { |item| items.include? item }
9-
end unless method_defined?(:except!)
10-
113
def extract_options!
124
last.is_a?(::Hash) ? pop : {}
135
end

lib/bitbucket_rest_api/core_ext/hash.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
class Hash # :nodoc:
22

3-
def except(*items) # :nodoc:
4-
self.dup.except!(*items)
5-
end unless method_defined?(:except)
6-
7-
def except!(*keys) # :nodoc:
8-
keys.each { |key| self.delete(key) }
9-
self
10-
end unless method_defined?(:except!)
11-
123
def symbolize_keys # :nodoc:
134
inject({}) do |hash, (key, value)|
145
hash[(key.to_sym rescue key) || key] = value

spec/bitbucket_rest_api/core_ext/array_spec.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,6 @@
33

44
describe Array do
55
let(:array) { [:a, :b, :c, :d, { key: :value }] }
6-
describe '#except' do
7-
it 'removes the keys' do
8-
new_array = array.except(:a, :b)
9-
10-
expect(new_array).to_not include(:a)
11-
expect(new_array).to_not include(:b)
12-
end
13-
end
14-
15-
describe '#except!' do
16-
it 'removes the keys from the self' do
17-
array = [:a, :b, :c, :d]
18-
array.except!(:a, :b)
19-
20-
expect(array).to_not include(:a)
21-
expect(array).to_not include(:b)
22-
end
23-
end
246

257
describe '#extract_options!' do
268
it 'selects a hash from the arguments list' do

spec/bitbucket_rest_api/core_ext/hash_spec.rb

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,6 @@
1212
@symbols = { :a => { :b => { :c => 1 } } }
1313
end
1414

15-
context '#except!' do
16-
it 'should respond to except!' do
17-
@nested_hash.should respond_to :except!
18-
copy = @nested_hash.dup
19-
copy.except!('b', 'a', 'c')
20-
expect(copy).to be_empty
21-
end
22-
end
23-
24-
context '#except' do
25-
it 'should respond to except' do
26-
@nested_hash.should respond_to :except
27-
end
28-
29-
it 'should remove key from the hash' do
30-
expect(@nested_hash.except('a')).to be_empty
31-
end
32-
end
33-
3415
context '#symbolize_keys' do
3516
it 'should respond to symbolize_keys' do
3617
expect(@nested_hash).to respond_to :symbolize_keys

0 commit comments

Comments
 (0)