Giter VIP home page Giter VIP logo

Comments (7)

thetamind avatar thetamind commented on July 20, 2024

Thanks for your bug report. I just ran into this confusing issue today.

from hashie.

thedavemarshall avatar thedavemarshall commented on July 20, 2024

I was diving into this, I think the best solution would be to have a class that inherits from Mash. Perhaps 'Smash', or 'safe mash' that raises an error when trying to assign a value to a reserved key? Thoughts?

from hashie.

jfouse avatar jfouse commented on July 20, 2024

I have run into this as well recently with the "display" key; Mash returns 'nil' instead of the value in the parsed data.

from hashie.

dblock avatar dblock commented on July 20, 2024

What do we want to do about this? I think this is a dup of #119, at the least. Yes?

from hashie.

hadees avatar hadees commented on July 20, 2024

I ran into the same issue with the "display" key. Although I can't actually the method in the code. I'm wondering if something else is setting this.

At the very least it should thrown an exception if you try to set a key that won't work.

from hashie.

poori avatar poori commented on July 20, 2024

Ran into it w/ the 'hash' key...

from hashie.

michaelherold avatar michaelherold commented on July 20, 2024

This is a duplicate of #119.

There are several ways of handling this behavior in Hashie 3.3.1:

  1. If you really want to override methods with the method accessor, you can create a custom subclass that includes Hashie::Extensions::MethodAccessWithOverride. This new mixin allows you to do just that - override these methods with the keys, while retaining access to the original method(s) by aliasing them with a double-underscore prefix.
  2. If you want an error when you try to set -- on a Mash -- a property that clashes with an existing method, you can mix Hashie::Extensions::Mash::SafeAssignment into your Mash class. There currently isn't an extension that just gives you a warning, but you could take a look at the SafeAssignment extension and easily write an extension that warns you instead.

I'm going to go ahead and close this issue.

from hashie.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.