Skip to content

Commit

Permalink
Remove code that was made duplicate in hashie#481
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbyMcWho committed Aug 19, 2019
1 parent 3a5191e commit 096d795
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
7 changes: 0 additions & 7 deletions lib/hashie/mash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,6 @@ def transform_keys(&blk)
end
end

with_minimum_ruby('2.5.0') do
def slice(*keys)
string_keys = keys.map { |key| convert_key(key) }
self.class.new(super(*string_keys))
end
end

protected

def method_name_and_suffix(method_name)
Expand Down
18 changes: 0 additions & 18 deletions spec/hashie/mash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1057,22 +1057,4 @@ class SubMash < Hashie::Mash
end
end
end

with_minimum_ruby('2.5.0') do
describe '#slice' do
subject { described_class.new(a: 'apple', b: 'banana') }
it 'accepts both string and symbol as key' do
expect(subject.slice(:a)).to eq('a' => 'apple')
expect(subject.slice('a')).to eq('a' => 'apple')
end

it 'returns an instance of the class it was called on' do
class KlassMash < Hashie::Mash; end
klass_mash = KlassMash.new('a' => 'apple', 'b' => 'banana')

expect(klass_mash.slice('a')).to be_a(KlassMash)
expect(klass_mash.slice(:a)).to be_a(KlassMash)
end
end
end
end

0 comments on commit 096d795

Please sign in to comment.