Class: Multisert
- Inherits:
-
Object
- Object
- Multisert
- Defined in:
- lib/multisert.rb,
lib/multisert/version.rb
Constant Summary collapse
- MAX_BUFFER_COUNT_DEFAULT =
10_000
- VERSION =
"0.0.1"
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#database ⇒ Object
Returns the value of attribute database.
-
#fields ⇒ Object
Returns the value of attribute fields.
- #max_buffer_count ⇒ Object
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
- #<<(entry) ⇒ Object
- #entries ⇒ Object
- #flush! ⇒ Object
-
#initialize(attrs = {}) ⇒ Multisert
constructor
A new instance of Multisert.
Constructor Details
#initialize(attrs = {}) ⇒ Multisert
Returns a new instance of Multisert.
10 11 12 13 14 |
# File 'lib/multisert.rb', line 10 def initialize attrs = {} attrs.each do |attr, value| self.send "#{attr}=", value end end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
4 5 6 |
# File 'lib/multisert.rb', line 4 def connection @connection end |
#database ⇒ Object
Returns the value of attribute database.
5 6 7 |
# File 'lib/multisert.rb', line 5 def database @database end |
#fields ⇒ Object
Returns the value of attribute fields.
7 8 9 |
# File 'lib/multisert.rb', line 7 def fields @fields end |
#max_buffer_count ⇒ Object
36 37 38 |
# File 'lib/multisert.rb', line 36 def max_buffer_count @max_buffer_count || MAX_BUFFER_COUNT_DEFAULT end |
#table ⇒ Object
Returns the value of attribute table.
6 7 8 |
# File 'lib/multisert.rb', line 6 def table @table end |
Instance Method Details
#<<(entry) ⇒ Object
24 25 26 27 28 |
# File 'lib/multisert.rb', line 24 def << entry entries << entry flush! if flush_buffer? entry end |
#entries ⇒ Object
20 21 22 |
# File 'lib/multisert.rb', line 20 def entries @entries ||= [] end |
#flush! ⇒ Object
30 31 32 33 34 |
# File 'lib/multisert.rb', line 30 def flush! return if buffer_empty? @connection.query multisert_sql reset_entries! end |