Class: Baza::Driver::Pg::Indexes
- Inherits:
-
Object
- Object
- Baza::Driver::Pg::Indexes
- Defined in:
- lib/baza/driver/pg/indexes.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
Instance Method Summary collapse
- #create_index(index_list, args = {}) ⇒ Object
-
#initialize(args) ⇒ Indexes
constructor
A new instance of Indexes.
Constructor Details
#initialize(args) ⇒ Indexes
Returns a new instance of Indexes.
4 5 6 |
# File 'lib/baza/driver/pg/indexes.rb', line 4 def initialize(args) @db = args.fetch(:db) end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
2 3 4 |
# File 'lib/baza/driver/pg/indexes.rb', line 2 def db @db end |
Instance Method Details
#create_index(index_list, args = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/baza/driver/pg/indexes.rb', line 8 def create_index(index_list, args = {}) sqls = Baza::Driver::Pg::CreateIndexSqlCreator.new(db: db, indexes: index_list, create_args: args, on_table: args.fetch(:table_name)).sqls unless args[:return_sql] db.transaction do sqls.each do |sql| db.query(sql) end end end sqls if args[:return_sql] end |