diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/active_relation/relations/relation.rb | 17 | ||||
-rw-r--r-- | lib/active_relation/relations/writing.rb | 5 |
2 files changed, 16 insertions, 6 deletions
diff --git a/lib/active_relation/relations/relation.rb b/lib/active_relation/relations/relation.rb index 9847cf2b7c..15782cde06 100644 --- a/lib/active_relation/relations/relation.rb +++ b/lib/active_relation/relations/relation.rb @@ -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 diff --git a/lib/active_relation/relations/writing.rb b/lib/active_relation/relations/writing.rb new file mode 100644 index 0000000000..3054e9b72f --- /dev/null +++ b/lib/active_relation/relations/writing.rb @@ -0,0 +1,5 @@ +module ActiveRelation + class Writing < Compound + abstract :call, :to_sql + end +end
\ No newline at end of file |