Class: DefaultingRowSet
- Inherits:
-
Object
- Object
- DefaultingRowSet
- Defined in:
- lib/dbexpect/defaulting_row_set.rb
Instance Attribute Summary collapse
-
#columns_in_order ⇒ Object
Returns the value of attribute columns_in_order.
-
#defaults ⇒ Object
Returns the value of attribute defaults.
-
#rows ⇒ Object
Returns the value of attribute rows.
Instance Method Summary collapse
- #add_row(column_values) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ DefaultingRowSet
constructor
A new instance of DefaultingRowSet.
- #insert_statements(schema, name) ⇒ Object
- #set_default(column, value) ⇒ Object
- #where_clauses ⇒ Object
Constructor Details
#initialize ⇒ DefaultingRowSet
Returns a new instance of DefaultingRowSet.
23 24 25 26 27 28 |
# File 'lib/dbexpect/defaulting_row_set.rb', line 23 def initialize @defaults = Hash.new @rows = [] @columns_in_order = [] end |
Instance Attribute Details
#columns_in_order ⇒ Object
Returns the value of attribute columns_in_order.
20 21 22 |
# File 'lib/dbexpect/defaulting_row_set.rb', line 20 def columns_in_order @columns_in_order end |
#defaults ⇒ Object
Returns the value of attribute defaults.
19 20 21 |
# File 'lib/dbexpect/defaulting_row_set.rb', line 19 def defaults @defaults end |
#rows ⇒ Object
Returns the value of attribute rows.
21 22 23 |
# File 'lib/dbexpect/defaulting_row_set.rb', line 21 def rows @rows end |
Instance Method Details
#add_row(column_values) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/dbexpect/defaulting_row_set.rb', line 35 def add_row(column_values) column_values.keys.map {|col| add_column(col) } defaulted_row = set_defaults_at_time_of_addition(column_values) @rows << Row.new(defaulted_row,@columns_in_order & defaulted_row.keys) @rows.last end |
#empty? ⇒ Boolean
53 54 55 |
# File 'lib/dbexpect/defaulting_row_set.rb', line 53 def empty? @rows.empty? end |
#insert_statements(schema, name) ⇒ Object
43 44 45 46 47 |
# File 'lib/dbexpect/defaulting_row_set.rb', line 43 def insert_statements(schema,name) @rows.collect do |row| row.insert_stmt(schema,name) end end |
#set_default(column, value) ⇒ Object
30 31 32 33 |
# File 'lib/dbexpect/defaulting_row_set.rb', line 30 def set_default(column,value) add_column(column) @defaults[column] = value end |
#where_clauses ⇒ Object
49 50 51 |
# File 'lib/dbexpect/defaulting_row_set.rb', line 49 def where_clauses @rows.map(&:where_clause) end |