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

Can't use Hashie::Trash with IndifferentAccess? #167

Closed
kardeiz opened this issue Jun 12, 2014 · 2 comments
Closed

Can't use Hashie::Trash with IndifferentAccess? #167

kardeiz opened this issue Jun 12, 2014 · 2 comments
Labels

Comments

@kardeiz
Copy link

kardeiz commented Jun 12, 2014

I've just started playing around with using Hashie to help build Rails form objects. I'd like to initialize a Hashie object with a HashWithIndifferentAccess (e.g., params), but also do some coercion/translation on the hash values. Something like this:

class VideoSearch < Hashie::Trash
  include Hashie::Extensions::Dash::IndifferentAccess
  property :per_page, default: 25, transform_with: lambda { |v| v.to_i }
end

However, the transform_with fails when I include the IndifferentAccess module; that is, the value is not converted to_i. If I comment out the include, then everything works as expected.

Any thoughts or solutions (other than calling symbolize_keys on my params hash before initialization)?

EDIT: I'm using Hashie 3.0.0.

@gregory
Copy link
Contributor

gregory commented Jun 19, 2014

@kardeiz i've opened a PR, this should be your fix!

dblock pushed a commit that referenced this issue Jun 19, 2014
@dblock
Copy link
Member

dblock commented Jun 19, 2014

Closed via 3ab15f2.

@dblock dblock closed this as completed Jun 19, 2014
numinit pushed a commit to numinit/hashie that referenced this issue Jul 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants