diff options
author | Douglas Willcocks <douglas@d-tw.org> | 2015-01-04 16:39:08 +0100 |
---|---|---|
committer | Douglas Willcocks <douglas@d-tw.org> | 2015-01-13 21:31:04 +0100 |
commit | 44d4babe37be2d0f035e60269bb84c9d15013297 (patch) | |
tree | 8854cca633dc40b389cc090e34055d4c53a688d5 | |
parent | 700aed2a5ce3cc38889835e7901355112b269a74 (diff) | |
download | hashie-44d4babe37be2d0f035e60269bb84c9d15013297.tar.gz |
Fix bug where Dash changes argument to `property`
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | lib/hashie/dash.rb | 2 | ||||
-rw-r--r-- | spec/hashie/dash_spec.rb | 12 |
3 files changed, 14 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index bec0958..7547553 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * [#259](https://github.com/intridia/hashie/pull/259): Fixed handling of default proc values in Mash - [@Erol](https://github.com/Erol). * [#260](https://github.com/intridia/hashie/pull/260): Added block support to Extensions::DeepMerge - [@galathius](https://github.com/galathius). * [#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). * Your contribution here. ## 3.3.2 (11/26/2014) diff --git a/lib/hashie/dash.rb b/lib/hashie/dash.rb index 22f6bc8..849629f 100644 --- a/lib/hashie/dash.rb +++ b/lib/hashie/dash.rb @@ -44,7 +44,7 @@ module Hashie unless instance_methods.map(&:to_s).include?("#{property_name}=") define_method(property_name) { |&block| self.[](property_name, &block) } - property_assignment = property_name.to_s.concat('=').to_sym + property_assignment = "#{property_name}=".to_sym define_method(property_assignment) { |value| self.[]=(property_name, value) } end diff --git a/spec/hashie/dash_spec.rb b/spec/hashie/dash_spec.rb index 0d5d345..1d44d5a 100644 --- a/spec/hashie/dash_spec.rb +++ b/spec/hashie/dash_spec.rb @@ -486,3 +486,15 @@ describe MixedPropertiesTest do expect { subject['symbol'] = 'updated' }.to raise_error(NoMethodError) end end + +context 'Dynamic Dash Class' do + it 'define property' do + klass = Class.new(Hashie::Dash) + my_property = 'my_property' + my_orig = my_property.dup + + klass.property(my_property) + + expect(my_property).to eq(my_orig) + end +end |