1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

annotated abstract methods on relation

This commit is contained in:
Nick Kallen 2008-03-13 22:56:00 -07:00
parent 384008b04b
commit cd9efb9eec
2 changed files with 16 additions and 6 deletions

View file

@ -1,5 +1,7 @@
module ActiveRelation
class Relation
abstract :attributes, :selects, :orders, :inserts, :groupings, :joins, :limit, :offset, :alias
def session
Session.new
end
@ -119,14 +121,17 @@ module ActiveRelation
def call(connection = engine.connection)
connection.select_all(to_sql)
end
def attribute_for_name(name)
attributes.detect { |a| a.alias_or_name.to_s == name.to_s }
end
module AttributeAccessors
def attribute_for_name(name)
attributes.detect { |a| a.alias_or_name.to_s == name.to_s }
end
def attribute_for_attribute(attribute)
attributes.detect { |a| a =~ attribute }
def attribute_for_attribute(attribute)
attributes.detect { |a| a =~ attribute }
end
end
include AttributeAccessors
def bind(relation)
self

View file

@ -0,0 +1,5 @@
module ActiveRelation
class Writing < Compound
abstract :call, :to_sql
end
end