Class: Dbmanager::Adapters::Mysql::Loader
- Inherits:
-
Object
- Object
- Dbmanager::Adapters::Mysql::Loader
- Includes:
- Connectable
- Defined in:
- lib/dbmanager/adapters/mysql.rb
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#tmp_file ⇒ Object
readonly
Returns the value of attribute tmp_file.
Instance Method Summary collapse
- #create_db_if_missing ⇒ Object
- #create_db_if_missing_command ⇒ Object
-
#initialize(target, tmp_file) ⇒ Loader
constructor
A new instance of Loader.
- #load ⇒ Object
- #load_command ⇒ Object
- #run ⇒ Object
Methods included from Connectable
Constructor Details
#initialize(target, tmp_file) ⇒ Loader
Returns a new instance of Loader.
60 61 62 63 |
# File 'lib/dbmanager/adapters/mysql.rb', line 60 def initialize(target, tmp_file) @target = target @tmp_file = tmp_file end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
58 59 60 |
# File 'lib/dbmanager/adapters/mysql.rb', line 58 def target @target end |
#tmp_file ⇒ Object (readonly)
Returns the value of attribute tmp_file.
58 59 60 |
# File 'lib/dbmanager/adapters/mysql.rb', line 58 def tmp_file @tmp_file end |
Instance Method Details
#create_db_if_missing ⇒ Object
70 71 72 |
# File 'lib/dbmanager/adapters/mysql.rb', line 70 def create_db_if_missing Dbmanager.execute! create_db_if_missing_command end |
#create_db_if_missing_command ⇒ Object
82 83 84 |
# File 'lib/dbmanager/adapters/mysql.rb', line 82 def create_db_if_missing_command "bundle exec rake db:create RAILS_ENV=#{target.name}" end |
#load ⇒ Object
74 75 76 |
# File 'lib/dbmanager/adapters/mysql.rb', line 74 def load Dbmanager.execute! load_command end |
#load_command ⇒ Object
78 79 80 |
# File 'lib/dbmanager/adapters/mysql.rb', line 78 def load_command "mysql #{params(target)} < '#{tmp_file}'" end |
#run ⇒ Object
65 66 67 68 |
# File 'lib/dbmanager/adapters/mysql.rb', line 65 def run create_db_if_missing load end |