Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion custom setter methods
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jeremy Evans  
View profile  
 More options Nov 29 2010, 11:39 am
From: Jeremy Evans <jeremyeva...@gmail.com>
Date: Mon, 29 Nov 2010 08:39:42 -0800 (PST)
Local: Mon, Nov 29 2010 11:39 am
Subject: Re: custom setter methods
On Nov 29, 6:22 am, Lorenzo <alie...@gmail.com> wrote:

> Hi, I'd like to filter the input of a setter, I saw model hooks but in this case it won't fit well since the column will not be touched in most cases.

> something like:

> def foo=(param)
>   self.foo = ...
> end

> wont work because ruby will call self until the nice error Stack level too deep. With DataMapper I could use set_attribute() method, is there an alternative for sequel, or i'll have to use a simple before_ hook?

With Sequel, it's even simpler, you just call super:

def foo=(param)
  super(param * 2)
end

In almost all cases in Sequel::Model, whenever you override a method,
you just call super.

Jeremy


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.