diff options
author | David Marshall <depmarshall@gmail.com> | 2013-07-17 10:46:16 -0700 |
---|---|---|
committer | David Marshall <depmarshall@gmail.com> | 2013-07-17 10:46:16 -0700 |
commit | 9bf80a18519d798224b76c33e8e523dfe42833e3 (patch) | |
tree | 0a21648e4a371a290e0fefe41097cef63d4bd913 /lib/hashie | |
parent | 3321005d0bd77e0811a2cea6dbbd302d8e86851f (diff) | |
download | hashie-9bf80a18519d798224b76c33e8e523dfe42833e3.tar.gz |
Adding support for dash properties that end in bang
Diffstat (limited to 'lib/hashie')
-rw-r--r-- | lib/hashie/dash.rb | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/hashie/dash.rb b/lib/hashie/dash.rb index a1669a5..ff46d58 100644 --- a/lib/hashie/dash.rb +++ b/lib/hashie/dash.rb @@ -39,15 +39,9 @@ module Hashie end unless instance_methods.map { |m| m.to_s }.include?("#{property_name}=") - class_eval <<-ACCESSORS - def #{property_name}(&block) - self.[](#{property_name.to_s.inspect}, &block) - end - - def #{property_name}=(value) - self.[]=(#{property_name.to_s.inspect}, value) - end - ACCESSORS + define_method(property_name) { |&block| self.[](property_name.to_s, &block) } + property_assignment = property_name.to_s.concat("=").to_sym + define_method(property_assignment) { |value| self.[]=(property_name.to_s, value) } end if defined? @subclasses |