spox wrote:
> I have a model that will downcase a field before storing. The problem is
> when attempting to filter using the value, it fails to return the result
> unless it is already downcased. I have tried various hooks to no avail.
> Is there any way for the final filter in the example below to work
> without explicitly downcasing the string?

The easiest way would be to add a new method:

  class Foobar
    def_dataset_method(:filter_by_name) do |name|
        filter(:name=>name.downcase)
    end
  end

If you absolutely must modify the filter method itself:

  class Foobar
    def_dataset_method(:filter) do |arg|
        return super unless Hash === arg
        h = arg.dup
        h.keys.each{|k| h[k] = h[k].downcase if k == :name}
        super(h)
    end
  end

I wouldn't recommend that, though, as it only fixes a particular
case.  Adding and using a new method is the best solution to the
issue.

Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to