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

Fixed inconsistency between Mash#respond_to? and #method_missing. Added Hashie::Extensions::Mash::ActiveModel for compatibility with Rails 4 Strong Parameters. #147

Merged
merged 1 commit into from
May 1, 2014

Conversation

dblock
Copy link
Member

@dblock dblock commented Apr 30, 2014

I would appreciate comments on the README and the implementation. Maybe there's a way to do this automatically via Railtie or something like that (I don't know how)?

class Mash
  include Hashie::Extensions::Mash::ActiveModel
end

Closes #146 and #89.

@dblock dblock changed the title Added Hashie::Extensions::Mash::ActiveModel for compatibility with Rails 4 Strong Parameters. Fixed inconsistency between Mash#respond_to? and #method_missing. Added Hashie::Extensions::Mash::ActiveModel for compatibility with Rails 4 Strong Parameters. Apr 30, 2014
@7even
Copy link
Contributor

7even commented Apr 30, 2014

The implementation seems great (though there is a slightly better way with #respond_to_missing). But I also don't really know how to hook Mash.include Hashie::Extensions::Mash::ActiveModel in rails.

@dblock
Copy link
Member Author

dblock commented Apr 30, 2014

@7even I was trying to keep method_missing and respond_to? in sync. Want to suggest better?

@dblock
Copy link
Member Author

dblock commented May 1, 2014

Note #143, which is fixed with this. I am going to merge and we can continue improving the code in subsequent PRs. @7even feel free to add.

dblock added a commit that referenced this pull request May 1, 2014
Fixed inconsistency between Mash#respond_to? and #method_missing. Added Hashie::Extensions::Mash::ActiveModel for compatibility with Rails 4 Strong Parameters.
@dblock dblock merged commit 6bb94f8 into hashie:master May 1, 2014
@dblock dblock deleted the mash-activemodel branch May 1, 2014 01:18
@Maxim-Filimonov
Copy link
Contributor

@dblock uh oh :\ Sorry for introducing the issue. To enable it automatically you can probably do something like this

if const_defined?('ActiveModel')
  include Hashie::Extensions::Mash::ActiveModel
end

I'll look at doing PR for this later today

@7even
Copy link
Contributor

7even commented May 1, 2014

@dblock well, that way was nearly the same except you define #respond_to_missing instead of #respond_to. I think it would be more correct because #respond_to_missing is designed exactly for #method_missing-powered methods. But it will work either way so you decide.

@dblock
Copy link
Member Author

dblock commented May 1, 2014

Oh I see. It's a lot better, implemented in 953edec.

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

Successfully merging this pull request may close these issues.

Mash#respond_to? inconsistent with #method_missing
3 participants