Module: Pacecar::Polymorph::ClassMethods

Defined in:
lib/pacecar/polymorph.rb

Instance Method Summary collapse

Instance Method Details

#has_polymorph(name) ⇒ Object



9
10
11
12
13
14
# File 'lib/pacecar/polymorph.rb', line 9

def has_polymorph(name)
  scope "for_#{name}_type".to_sym, lambda { |type|
    polymorph_type = "#{name}_type"
    { :conditions => ["#{quoted_table_name}.#{connection.quote_column_name polymorph_type} = ?", type.to_s] }
  }
end