Class: Baza::Driver::Sqlite3::Index
- Inherits:
-
Index
- Object
- Index
- Baza::Driver::Sqlite3::Index
show all
- Defined in:
- lib/baza/drivers/sqlite3/index.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Index
#inspect, #to_s
Constructor Details
#initialize(args) ⇒ Index
Returns a new instance of Index.
4
5
6
7
8
|
# File 'lib/baza/drivers/sqlite3/index.rb', line 4
def initialize(args)
@args = args
@columns = []
@db = args[:db]
end
|
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
2
3
4
|
# File 'lib/baza/drivers/sqlite3/index.rb', line 2
def args
@args
end
|
#columns ⇒ Object
Returns the value of attribute columns.
2
3
4
|
# File 'lib/baza/drivers/sqlite3/index.rb', line 2
def columns
@columns
end
|
Instance Method Details
#column_names ⇒ Object
45
46
47
|
# File 'lib/baza/drivers/sqlite3/index.rb', line 45
def column_names
@columns
end
|
#data ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/baza/drivers/sqlite3/index.rb', line 37
def data
return {
name: name,
unique: unique?,
columns: @columns
}
end
|
#drop ⇒ Object
22
23
24
|
# File 'lib/baza/drivers/sqlite3/index.rb', line 22
def drop
@db.query("DROP INDEX `#{name}`")
end
|
#name ⇒ Object
10
11
12
|
# File 'lib/baza/drivers/sqlite3/index.rb', line 10
def name
return @args[:data][:name]
end
|
#rename(newname) ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/baza/drivers/sqlite3/index.rb', line 26
def rename(newname)
newname = newname.to_sym
create_args = data
create_args[:name] = newname
drop
table.create_indexes([create_args])
@args[:data][:name] = newname
end
|
#table ⇒ Object
18
19
20
|
# File 'lib/baza/drivers/sqlite3/index.rb', line 18
def table
return @db.tables[table_name]
end
|
#table_name ⇒ Object
14
15
16
|
# File 'lib/baza/drivers/sqlite3/index.rb', line 14
def table_name
return @args[:table_name]
end
|
#unique? ⇒ Boolean
49
50
51
|
# File 'lib/baza/drivers/sqlite3/index.rb', line 49
def unique?
@args[:data][:unique].to_i == 1
end
|