Class: Marsdawn::Storage
- Inherits:
-
Object
show all
- Defined in:
- lib/marsdawn/storage.rb
Defined Under Namespace
Classes: ActiveRecord, Base, FileSystem, Test, TestNotImplementedError
Class Method Summary
collapse
Class Method Details
.get(config, opts = {}) ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'lib/marsdawn/storage.rb', line 5
def self.get config, opts={}
opts = {key: 'default', lang: 'en', version: '0.0.1'}.merge(opts)
config = handle_config(config, opts)
raise "No storage type is specified." unless config.key?(:type)
class_name = config[:type]
@@base_path ||= File.join(File.dirname(__FILE__), 'storage')
Marsdawn::Util.adapter(self, class_name, @@base_path).new config, opts
end
|
.handle_config(config, opts) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/marsdawn/storage.rb', line 14
def self.handle_config config, opts
if config.nil?
Marsdawn::Config.new.get(opts[:key], :storage)
else
Marsdawn::Util.hash_symbolize_keys(config)
end
end
|