add Hashie::Mash#extractable_options?

This commit is contained in:
Ryan Buckley 2015-01-19 11:37:14 -08:00
parent 32d904b789
commit 86a141598f
4 changed files with 19 additions and 1 deletions

View File

@ -12,7 +12,7 @@ Metrics/AbcSize:
# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 165
Max: 170
# Offense count: 8
Metrics/CyclomaticComplexity:

View File

@ -10,6 +10,7 @@
* [#254](https://github.com/intridea/hashie/pull/254): Added public utility methods for stringify and symbolize keys - [@maxlinc](https://github.com/maxlinc).
* [#261](https://github.com/intridea/hashie/pull/261): Fixed bug where Dash.property modifies argument object - [@d_tw](https://github.com/d_tw).
* [#264](https://github.com/intridea/hashie/pull/264): Methods such as abc? return true/false with Hashie::Extensions::MethodReader - [@Zloy](https://github.com/Zloy).
* [#269](https://github.com/intridea/hashie/pull/269): Add #extractable_options? so ActiveSupport Array#extract_options! can extract it - [@ridiculous](https://github.com/ridiculous).
* Your contribution here.
## 3.3.2 (11/26/2014)

View File

@ -250,6 +250,11 @@ module Hashie
end
end
# play nice with ActiveSupport Array#extract_options!
def extractable_options?
true
end
protected
def method_suffix(method_name)

View File

@ -639,4 +639,16 @@ describe Hashie::Mash do
end
end
end
describe '#extractable_options?' do
require 'active_support'
subject { described_class.new(name: 'foo') }
let(:args) { [101, 'bar', subject] }
it 'can be extracted from an array' do
expect(args.extract_options!).to eq subject
expect(args).to eq [101, 'bar']
end
end
end