Module: Cardio::Utils
- Included in:
- Cardio
- Defined in:
- lib/cardio/utils.rb
Overview
Utilities that may need to be run even when mods are not loaded.
Instance Method Summary collapse
- #database_name ⇒ Object
-
#delete_tmp_files!(id = nil) ⇒ Object
deletes tmp directory within files directory It’s here because it gets called as part of cache clearing, which sometimes gets called in a context where card mods are not loaded.
- #seed_test_db ⇒ Object
- #t(key, args = {}) ⇒ Object
Instance Method Details
#database_name ⇒ Object
12 13 14 |
# File 'lib/cardio/utils.rb', line 12 def database_name @database_name ||= config.database_configuration.dig Rails.env, "database" end |
#delete_tmp_files!(id = nil) ⇒ Object
deletes tmp directory within files directory It’s here because it gets called as part of cache clearing, which sometimes gets called in a context where card mods are not loaded. Why does cache clearing need to do this??
20 21 22 23 24 25 26 |
# File 'lib/cardio/utils.rb', line 20 def delete_tmp_files! id=nil raise "no files directory" unless files_dir delete_tmp_files id rescue StandardError Rails.logger.info "failed to remove tmp files" end |
#seed_test_db ⇒ Object
8 9 10 |
# File 'lib/cardio/utils.rb', line 8 def seed_test_db system "env RAILS_ENV=test bundle exec rake db:fixtures:load" end |
#t(key, args = {}) ⇒ Object
4 5 6 |
# File 'lib/cardio/utils.rb', line 4 def t key, args={} ::I18n.t key, args end |