Class: Rails::Sequel::Storage
- Inherits:
-
Object
- Object
- Rails::Sequel::Storage
show all
- Defined in:
- lib/sequel-rails/storage.rb
Defined Under Namespace
Classes: Jdbc, Mysql, Postgres, Sqlite
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(config) ⇒ Storage
Returns a new instance of Storage.
78
79
80
|
# File 'lib/sequel-rails/storage.rb', line 78
def initialize(config)
@config = config
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
24
25
26
|
# File 'lib/sequel-rails/storage.rb', line 24
def config
@config
end
|
Class Method Details
.create_all ⇒ Object
26
27
28
|
# File 'lib/sequel-rails/storage.rb', line 26
def self.create_all
with_local_repositories { |config| create_environment(config) }
end
|
.create_environment(config) ⇒ Object
34
35
36
|
# File 'lib/sequel-rails/storage.rb', line 34
def self.create_environment(config)
new(config).create
end
|
.drop_all ⇒ Object
30
31
32
|
# File 'lib/sequel-rails/storage.rb', line 30
def self.drop_all
with_local_repositories { |config| drop_environment(config) }
end
|
.drop_environment(config) ⇒ Object
38
39
40
|
# File 'lib/sequel-rails/storage.rb', line 38
def self.drop_environment(config)
new(config).drop
end
|
.new(config) ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/sequel-rails/storage.rb', line 42
def self.new(config)
config = Rails::Sequel.configuration.environments[config.to_s] unless config.kind_of?(Hash)
klass = lookup_class(config['adapter'])
if klass.equal?(self)
super(config)
else
klass.new(config)
end
end
|
Instance Method Details
#charset ⇒ Object
124
125
126
|
# File 'lib/sequel-rails/storage.rb', line 124
def charset
@charset ||= config['charset'] || ENV['CHARSET'] || 'utf8'
end
|
#create ⇒ Object
82
83
84
85
86
87
88
|
# File 'lib/sequel-rails/storage.rb', line 82
def create
if _create
puts "[sequel] Created database '#{database}'"
else
puts "[sequel] FAILED to create database '#{database}'"
end
end
|
#database ⇒ Object
99
100
101
|
# File 'lib/sequel-rails/storage.rb', line 99
def database
@database ||= config['database'] || config['path']
end
|
#drop ⇒ Object
90
91
92
93
94
95
96
97
|
# File 'lib/sequel-rails/storage.rb', line 90
def drop
::Sequel::Model.db.disconnect
if _drop
puts "[sequel] Dropped database '#{database}'"
else
puts "[sequel] FAILED to drop database '#{database}'"
end
end
|
#host ⇒ Object
111
112
113
|
# File 'lib/sequel-rails/storage.rb', line 111
def host
@host ||= config['host'] || ''
end
|
#owner ⇒ Object
119
120
121
|
# File 'lib/sequel-rails/storage.rb', line 119
def owner
@owner ||= config['owner'] || ''
end
|
#password ⇒ Object
107
108
109
|
# File 'lib/sequel-rails/storage.rb', line 107
def password
@password ||= config['password'] || ''
end
|
#port ⇒ Object
115
116
117
|
# File 'lib/sequel-rails/storage.rb', line 115
def port
@port ||= config['port'] || ''
end
|
#username ⇒ Object
103
104
105
|
# File 'lib/sequel-rails/storage.rb', line 103
def username
@username ||= config['username'] || config['user'] || ''
end
|