Giter Site home page Giter Site logo

Comments (5)

zilkey avatar zilkey commented on August 11, 2024

Thanks for using ActiveHash, and for taking the time to report the issue. I can't think of a reason why you would need to call save on an activehash object that's already been saved. Only one copy of that object will exist in memory, so just updating an attribute should be sufficient.

I agree that having save blow up on a record that is already part of the collection. It seems like we have a few ways to fix this:

  • raise an error that's more specific, like "There's no need to save an object that already has an id"
  • implement a save method that is a no-op if you call it on an object with an id

Which one seems like the better option to you?

from active_hash.

pisaruk avatar pisaruk commented on August 11, 2024

I think that having a no-op save method and displaying the warning "There's no need to save an object that already has an id" would be the best approach.
What do you think?

from active_hash.

zilkey avatar zilkey commented on August 11, 2024

I think I prefer the no-op on its own, no logging (just so we don't fill up logs unnecessarily).

I'll add that today.

from active_hash.

zilkey avatar zilkey commented on August 11, 2024

Just pushed version 1.0.0 that has a no-op save for existing objects, and also adds the exists? method on the class.

Thanks again

from active_hash.

pisaruk avatar pisaruk commented on August 11, 2024

Nice. Thank you.

from active_hash.

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.