Couchrest_model method to verify if attribute changed (dirty)

15 views
Skip to first unread message

Lucas Renan

unread,
Apr 19, 2011, 10:10:59 PM4/19/11
to CouchRest
Anyone knows if Couchrest model supports some verification for
attributes changes? like ar dirty:

person = Person.find_by_name('uncle bob')
person.changed? # => false
person.name = 'Bob'
person.changed? # => true
person.name_changed? # => true
person.name_was # => 'uncle bob'
person.name_change # => ['uncle bob', 'Bob']
person.name = 'Bill'
person.name_change # => ['uncle bob', 'Bill']

Samuel Lown

unread,
Apr 20, 2011, 4:33:33 AM4/20/11
to couc...@googlegroups.com
Hi,

This has been attempted a couple of times in the past, but performance issues and the problem with dealing with nested models always sets it back.

The following pull request looks very promising if you want to check it out, I've had other priorities recently but I hope to check it out soon:


Cheers,
sam



--
You received this message because you are subscribed to the Google Groups "CouchRest" group.
To post to this group, send email to couc...@googlegroups.com.
To unsubscribe from this group, send email to couchrest+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/couchrest?hl=en.




--
www.samlown.com
www.autofiscal.com
www.planetaki.com/sam

Lucas Renan

unread,
Apr 20, 2011, 5:37:13 PM4/20/11
to CouchRest
Hi Sam,

thanks for your reply,
this kind of issue related with performance is really complicated.

In the case, I'm building a lib to create slugs. Then, slugs can not
be regenerated if property has not been changed.
Maybe I'll add some type of verification while this feature is not
added to the project.

Lucas

On 20 abr, 05:33, Samuel Lown <sam.l...@gmail.com> wrote:
> Hi,
>
> This has been attempted a couple of times in the past, but performance
> issues and the problem with dealing with nested models always sets it back.
>
> The following pull request looks very promising if you want to check it out,
> I've had other priorities recently but I hope to check it out soon:
>
> https://github.com/couchrest/couchrest_model/pull/58
>
> Cheers,
> sam
> <https://github.com/couchrest/couchrest_model/pull/58>

Samuel Lown

unread,
Apr 21, 2011, 5:52:12 AM4/21/11
to couc...@googlegroups.com
Hi Lucas,

Your question yesterday prompted me to have another look at the pull request I mentioned. I actually tested it out, made a few minor modifications and included it in the 1.1.0.beta4 release.

Check it out, you should be able to do a @model.title_changed? without problem, and performance seems to be fine.

Cheers,
sam

Lucas Renan

unread,
Apr 24, 2011, 4:07:18 PM4/24/11
to CouchRest
Thanx Sam =)

On 21 abr, 06:52, Samuel Lown <sam.l...@gmail.com> wrote:
> Hi Lucas,
>
> Your question yesterday prompted me to have another look at the pull request
> I mentioned. I actually tested it out, made a few minor modifications and
> included it in the 1.1.0.beta4 release.
>
> Check it out, you should be able to do a @model.title_changed? without
> problem, and performance seems to be fine.
>
> Cheers,
> sam
>
Reply all
Reply to author
Forward
0 new messages