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

What does save and save! method do? #96

Open
kapso opened this issue Dec 28, 2013 · 6 comments
Open

What does save and save! method do? #96

kapso opened this issue Dec 28, 2013 · 6 comments

Comments

@kapso
Copy link

kapso commented Dec 28, 2013

I am new to RubyMotion/MotionModel and was looking at different persistence options.
I came across this issue #12 and this recommends calling serialize/deserialize explicitly.

If thats the case then what does method save & save! do?

@sxross
Copy link
Owner

sxross commented Dec 28, 2013

Because the ArrayModelAdapter is moving stuff around in volatile memory, you do have to explicitly call the persistence methods to store the data in nonvolatile memory. This was an implementation decision that may seem jarring if you are used to Rails and discrete saves to NV storage. In our case, I didn't want to presume anything that might negatively impact performance.

Does this help explain?

@kapso
Copy link
Author

kapso commented Dec 28, 2013

As a newbie its confusing for sure, it took me a while to realize that save is not actually "saving". May be adding a note to save documentation would help. Also may be a design change where serialization is provided out of the box (but made optional) would help.

@sxross
Copy link
Owner

sxross commented Dec 28, 2013

There is an example under notifications that should give you a good idea how to make save mean save. But point taken about the README. If you want to take a crack at it and submit a pull request, that would be great.

@kapso
Copy link
Author

kapso commented Dec 28, 2013

Ok I will take a look. Also what does MotionModel::ArrayModelAdapter provide? Do I need that?

@sxross
Copy link
Owner

sxross commented Dec 28, 2013

There are two branches. Master requires you include the ArrayModelAdapter. The SQL branch uses FMDB and the SQLite database. You should look at the example and docs in the SQL branch if you want to use that.

To answer your question, ArrayModelAdapter provides finder, persistence etc. specific to the backing store.

@kapso
Copy link
Author

kapso commented Dec 28, 2013

So does that mean delete_all and destroy_all remove the data from memory only? at least thats what I am seeing. This is all very confusing :)

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

No branches or pull requests

2 participants