Class: RailsSqlViews::ConnectionAdapters::ViewDefinition
- Inherits:
-
Object
- Object
- RailsSqlViews::ConnectionAdapters::ViewDefinition
- Defined in:
- lib/rails_sql_views/connection_adapters/abstract/schema_definitions.rb
Overview
Abstract definition of a View
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#select_query ⇒ Object
Returns the value of attribute select_query.
Instance Method Summary collapse
- #column(name) ⇒ Object
-
#initialize(base, select_query) ⇒ ViewDefinition
constructor
A new instance of ViewDefinition.
- #to_sql ⇒ Object
Constructor Details
#initialize(base, select_query) ⇒ ViewDefinition
Returns a new instance of ViewDefinition.
7 8 9 10 11 |
# File 'lib/rails_sql_views/connection_adapters/abstract/schema_definitions.rb', line 7 def initialize(base, select_query) @columns = [] @base = base @select_query = select_query end |
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
5 6 7 |
# File 'lib/rails_sql_views/connection_adapters/abstract/schema_definitions.rb', line 5 def columns @columns end |
#select_query ⇒ Object
Returns the value of attribute select_query.
5 6 7 |
# File 'lib/rails_sql_views/connection_adapters/abstract/schema_definitions.rb', line 5 def select_query @select_query end |
Instance Method Details
#column(name) ⇒ Object
13 14 15 16 17 |
# File 'lib/rails_sql_views/connection_adapters/abstract/schema_definitions.rb', line 13 def column(name) column = name.to_s @columns << column unless @columns.include? column self end |
#to_sql ⇒ Object
19 20 21 |
# File 'lib/rails_sql_views/connection_adapters/abstract/schema_definitions.rb', line 19 def to_sql @columns.collect { |c| @base.quote_column_name(c) } * ', ' end |