Class: Bootstrap::Db::Adapter
- Inherits:
-
Object
- Object
- Bootstrap::Db::Adapter
- Includes:
- Command
- Defined in:
- lib/bootstrap/db/adapter.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
Instance Method Summary collapse
- #additional_parameters ⇒ Object
-
#command_string ⇒ Object
implemented by adapters.
- #current_db_time ⇒ Object
-
#default_file_name ⇒ Object
implemented by adapters.
- #ignore_tables ⇒ Object
-
#initialize(config) ⇒ Adapter
constructor
A new instance of Adapter.
Methods included from Command
#display_and_execute, #execute_command
Constructor Details
#initialize(config) ⇒ Adapter
Returns a new instance of Adapter.
8 9 10 11 12 13 |
# File 'lib/bootstrap/db/adapter.rb', line 8 def initialize(config) @config = config @file_name = ENV['FILE_NAME'] || default_file_name @file_path = File.(File.join(config.bootstrap_dir, file_name)) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/bootstrap/db/adapter.rb', line 6 def config @config end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
6 7 8 |
# File 'lib/bootstrap/db/adapter.rb', line 6 def file_name @file_name end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
6 7 8 |
# File 'lib/bootstrap/db/adapter.rb', line 6 def file_path @file_path end |
Instance Method Details
#additional_parameters ⇒ Object
31 32 33 34 35 |
# File 'lib/bootstrap/db/adapter.rb', line 31 def additional_parameters @optional_parameters ||= begin ENV['ADDITIONAL_PARAMS'].split(',') if ENV['ADDITIONAL_PARAMS'] end end |
#command_string ⇒ Object
implemented by adapters
16 17 18 |
# File 'lib/bootstrap/db/adapter.rb', line 16 def command_string raise NotImplementedError end |
#current_db_time ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bootstrap/db/adapter.rb', line 37 def current_db_time if Time.respond_to?(:zone) #Handle custom timezones if time_zone = (ENV['TZ'] || ENV['ZONEBIE_TZ']) Time.zone ||= time_zone end Time.zone.now else Time.now end.to_formatted_s(:db) end |
#default_file_name ⇒ Object
implemented by adapters
21 22 23 |
# File 'lib/bootstrap/db/adapter.rb', line 21 def default_file_name raise NotImplementedError end |
#ignore_tables ⇒ Object
25 26 27 28 29 |
# File 'lib/bootstrap/db/adapter.rb', line 25 def ignore_tables @ignore_tables ||= begin ENV['IGNORE_TABLES'].split(',') if ENV['IGNORE_TABLES'] end end |