Giter Site home page Giter Site logo

Comments (5)

solnic avatar solnic commented on July 23, 2024

Currently DataMapper only tracks changes caused by calling the mutator methods, not changes using the reference to the value internally.

So for example, if you have a String, and you set the user.name using user.name = "gondar", and then later you use user.name << "other" to append to the String, DataMapper isn’t going to notice the change since you modified the value that it has a reference to.

DataMapper used to track this sort of change, but it incurred a large overhead and was needlessly complex. I removed it until we could figure out a better approach.

I suppose it may be possible if we take a snapshot of the object attributes’ Object#hash values when it is loaded, and then compare those when it comes time to save the object. I’m not yet sure what sort of overhead this will have, but it may be worth looking into later.

For now I am going to mark this as a "suggestion" and we will revisit it prior to 1.0

by Dan Kubb (dkubb)

from dm-types.

solnic avatar solnic commented on July 23, 2024

I wish this ticket were higher on google, but here’s a workaround for anyone else who, like me, finds this type not very useful without this feature. Unfortunately, it will always save the YAML property if it has been loaded at all.

before :save, :dump_yaml

def dump_yaml
  self.yaml_prop = YAML.dump(self.yaml_prop) if attribute_loaded? :yaml_prop
end

by blavender (at gmail)

from dm-types.

solnic avatar solnic commented on July 23, 2024

I added a pending spec for this and sent a pull request, see http://github.com/bhuga/dm-more/commit/e09a0579290a7036ee19f4d9f8c173ebad2a9654

by blavender (at gmail)

from dm-types.

jpr5 avatar jpr5 commented on July 23, 2024

Note that pull request 33 (#33) would fix this use case.

from dm-types.

dkubb avatar dkubb commented on July 23, 2024

@jpr5's pull request was merged which solves this problem. Closing this ticket.

If the problem still persists please add a comment to this ticket, otherwise enjoy!

from dm-types.

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.