On Thursday, December 4, 2014 12:42:39 PM UTC-8, Stefan Novak wrote:
>
> Hi!
>
> I'm trying to figure out a clean approach for referencing an expression 
> within a Model. For example:
>
> class Person < Sequel::Model
>   def self.gender_title
>     Sequel.case({
>     :M  => "Men's",
>     :W  => "Women's"},
>     "Not Applicable",
>     :gender)
>   end
> end
>
>
> I can run Person.select(Person.gender_title).sql and it generates the 
> proper SQL. Is there a way to alias this expression to be 
> Person.select(:gender_title)?
>

If you just want to alias the expression:
 
Person.select(Person.gender_title.as(:gender_title)).sql

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to