Class: SequelRails::Storage::Abstract
- Inherits:
-
Object
- Object
- SequelRails::Storage::Abstract
show all
- Defined in:
- lib/sequel_rails/storage/abstract.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(config) ⇒ Abstract
Returns a new instance of Abstract.
6
7
8
9
|
# File 'lib/sequel_rails/storage/abstract.rb', line 6
def initialize(config)
@config = config
parse_url
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
4
5
6
|
# File 'lib/sequel_rails/storage/abstract.rb', line 4
def config
@config
end
|
Instance Method Details
#charset ⇒ Object
67
68
69
|
# File 'lib/sequel_rails/storage/abstract.rb', line 67
def charset
@charset ||= config['charset'] || ENV['CHARSET'] || 'utf8'
end
|
#close_connections ⇒ Object
To be overriden by subclasses
39
40
41
|
# File 'lib/sequel_rails/storage/abstract.rb', line 39
def close_connections
true
end
|
#collation ⇒ Object
71
72
73
|
# File 'lib/sequel_rails/storage/abstract.rb', line 71
def collation
@collation ||= config['collation'] || ENV['COLLATION']
end
|
#create ⇒ Object
11
12
13
14
15
|
# File 'lib/sequel_rails/storage/abstract.rb', line 11
def create
res = _create
warn "[sequel] Created database '#{database}'" if res
res
end
|
#database ⇒ Object
43
44
45
|
# File 'lib/sequel_rails/storage/abstract.rb', line 43
def database
@database ||= config['database'] || config['path']
end
|
#drop ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/sequel_rails/storage/abstract.rb', line 17
def drop
return if ::Sequel::DATABASES.size == 0
::Sequel::Model.db.disconnect
res = _drop
warn "[sequel] Dropped database '#{database}'" if res
res
end
|
#dump(filename) ⇒ Object
26
27
28
29
30
|
# File 'lib/sequel_rails/storage/abstract.rb', line 26
def dump(filename)
res = _dump filename
warn "[sequel] Dumped structure of database '#{database}' to '#{filename}'" if res
res
end
|
#host ⇒ Object
55
56
57
|
# File 'lib/sequel_rails/storage/abstract.rb', line 55
def host
@host ||= config['host'] || ''
end
|
#load(filename) ⇒ Object
32
33
34
35
36
|
# File 'lib/sequel_rails/storage/abstract.rb', line 32
def load(filename)
res = _load filename
warn "[sequel] Loaded structure of database '#{database}' from '#{filename}'" if res
res
end
|
#owner ⇒ Object
63
64
65
|
# File 'lib/sequel_rails/storage/abstract.rb', line 63
def owner
@owner ||= config['owner'] || ''
end
|
#password ⇒ Object
51
52
53
|
# File 'lib/sequel_rails/storage/abstract.rb', line 51
def password
@password ||= config['password'] || ''
end
|
#port ⇒ Object
59
60
61
|
# File 'lib/sequel_rails/storage/abstract.rb', line 59
def port
@port ||= config['port'] || ''
end
|
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/sequel_rails/storage/abstract.rb', line 79
def schema_information_dump(migrator, sql_dump)
res = ''
inserts = schema_information_inserts(migrator, sql_dump)
if inserts.any?
res = inserts.join("\n")
unless sql_dump
res = <<-RUBY.strip_heredoc
Sequel.migration do
change do
#{res}
end
end
RUBY
end
end
res
end
|
#search_path ⇒ Object
75
76
77
|
# File 'lib/sequel_rails/storage/abstract.rb', line 75
def search_path
@search_path ||= config['search_path'] || '"$user", public'
end
|
#username ⇒ Object
47
48
49
|
# File 'lib/sequel_rails/storage/abstract.rb', line 47
def username
@username ||= config['username'] || config['user'] || ''
end
|