Class: LogStash::Filters::Jdbc::DbObject
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Validatable
find_validation_errors, #formatted_errors, #initialize, #valid?
Instance Attribute Details
#columns ⇒ Object
10
11
12
|
# File 'lib/logstash/filters/jdbc/db_object.rb', line 10
def columns
@columns
end
|
#index_columns ⇒ Object
10
11
12
|
# File 'lib/logstash/filters/jdbc/db_object.rb', line 10
def index_columns
@index_columns
end
|
#name ⇒ Object
10
11
12
|
# File 'lib/logstash/filters/jdbc/db_object.rb', line 10
def name
@name
end
|
#preserve_existing ⇒ Object
10
11
12
|
# File 'lib/logstash/filters/jdbc/db_object.rb', line 10
def preserve_existing
@preserve_existing
end
|
Instance Method Details
#<=>(other) ⇒ Object
28
29
30
|
# File 'lib/logstash/filters/jdbc/db_object.rb', line 28
def <=>(other)
@name <=> other.name
end
|
#build(db) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/logstash/filters/jdbc/db_object.rb', line 12
def build(db)
return unless valid?
if db.nil?
raise "DbObject given a database instance that is nil"
end
schema_gen = db.create_table_generator()
@columns.each {|col| schema_gen.column(col.name, col.datatype)}
schema_gen.index(@index_columns) unless @index_columns.empty?
options = {:generator => schema_gen}
if @preserve_existing
db.create_table?(@name, options)
else
db.create_table(@name, options)
end
end
|
#inspect ⇒ Object
36
37
38
|
# File 'lib/logstash/filters/jdbc/db_object.rb', line 36
def inspect
"<LogStash::Filters::Jdbc::DbObject name: #{@name}, columns: #{@columns.inspect}>"
end
|
#to_s ⇒ Object
32
33
34
|
# File 'lib/logstash/filters/jdbc/db_object.rb', line 32
def to_s
inspect
end
|