Module: VirtualView::ActiveRecord::Relation
- Defined in:
- lib/virtual_view/active_record/relation.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.prepended(subclass) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/virtual_view/active_record/relation.rb', line 8 def self.prepended(subclass) class << subclass class_attribute :arel_view self.arel_view = false end subclass.extend(ClassMethods) end |
Instance Method Details
#arel_view ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/virtual_view/active_record/relation.rb', line 16 def arel_view self.class.arel_view.call.tap do |ar_view| unless ar_view.projections.any? ar_view.project(arel_table[Arel.star]) end end end |
#from_clause ⇒ Object
28 29 30 |
# File 'lib/virtual_view/active_record/relation.rb', line 28 def from_clause ::ActiveRecord::Relation::FromClause.new(table_view, table_name) end |
#from_value ⇒ Object
32 33 34 |
# File 'lib/virtual_view/active_record/relation.rb', line 32 def from_value table_view.to_sql end |
#table_view ⇒ Object
24 25 26 |
# File 'lib/virtual_view/active_record/relation.rb', line 24 def table_view arel_table.create_table_alias(arel_view, table_name) end |