Class: RailsSqlViews::ConnectionAdapters::ViewDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_sql_views/connection_adapters/abstract/schema_definitions.rb

Overview

Abstract definition of a View

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#columnsObject

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_queryObject

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_sqlObject



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