Module: BackgroundQueue::Utils
- Defined in:
- lib/background_queue/utils.rb
Overview
Utility Module
Defined Under Namespace
Classes: AnyKeyHash
Class Method Summary collapse
- .current_environment ⇒ Object
- .current_root ⇒ Object
-
.get_hash_entry(hash, key) ⇒ Object
gets an entry from a hash regardless if the key is a string or symbol.
Class Method Details
.current_environment ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/background_queue/utils.rb', line 5 def self.current_environment if ENV.has_key?('RAILS_ENV') ENV['RAILS_ENV'] elsif defined? Rails Rails.env end end |
.current_root ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/background_queue/utils.rb', line 13 def self.current_root if defined? RAILS_ROOT RAILS_ROOT elsif defined? Rails Rails.root end end |
.get_hash_entry(hash, key) ⇒ Object
gets an entry from a hash regardless if the key is a string or symbol
22 23 24 25 26 27 28 29 30 |
# File 'lib/background_queue/utils.rb', line 22 def self.get_hash_entry(hash, key) if hash.has_key?(key) hash[key] elsif key.kind_of?(String) hash[key.intern] else hash[key.to_s] end end |