Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MethodAccessWithOverride does not apply to existing hash #338

Open
jeremy-hubble opened this issue Dec 30, 2015 · 1 comment
Open

MethodAccessWithOverride does not apply to existing hash #338

jeremy-hubble opened this issue Dec 30, 2015 · 1 comment

Comments

@jeremy-hubble
Copy link

MethodAccessWithOverride only overrides default methods when the item is manually set. I would like to be able to have methods available when creating from an existing hash.

class MyOverridingHash < Hash
  include Hashie::Extensions::MethodAccessWithOverride
end

hash = {}
hash['key'] = 'foo';
hash['val'] = 'bar';
overriding = MyOverridingHash.new(hash)
overriding.key   # produces error. Expect 'foo'
overriding.key = 'foo'
overriding.key  # 'foo'
@dblock
Copy link
Member

dblock commented Jan 2, 2016

It's possible that we want to change behavior of MethodAccessWithOverride to do this, or have another MethodAccessWithOverrideInitializer or similar. I would explore both routes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants