Class: Qdsl::ColumnSet
- Inherits:
-
Object
- Object
- Qdsl::ColumnSet
- Defined in:
- lib/column_set.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
Instance Method Summary collapse
- #capture(source, join_sources) ⇒ Object
-
#initialize(columns, block) ⇒ ColumnSet
constructor
A new instance of ColumnSet.
Constructor Details
#initialize(columns, block) ⇒ ColumnSet
5 6 7 8 |
# File 'lib/column_set.rb', line 5 def initialize(columns, block) @columns = columns.collect { |x| Column[x] } @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'lib/column_set.rb', line 3 def block @block end |
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
3 4 5 |
# File 'lib/column_set.rb', line 3 def columns @columns end |
Instance Method Details
#capture(source, join_sources) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/column_set.rb', line 10 def capture(source, join_sources) sources = [source] + join_sources columns = @columns.collect { |x| x.with_source(source) } + if @block proxies = sources.collect { |x| ColumnProxy.new(x) } [*@block.call(Util::fix_block_params(proxies))] else [] end undefined_columns = columns.select { |x| !x.exists? } raise "One or more undefined columns: #{undefined_columns.collect(&:name).join(', ')}" unless undefined_columns.empty? columns end |