Class: Schked::Config
- Inherits:
-
Object
- Object
- Schked::Config
- Defined in:
- lib/schked/config.rb
Instance Attribute Summary collapse
-
#do_not_load_root_schedule ⇒ Object
writeonly
Sets the attribute do_not_load_root_schedule.
- #logger ⇒ Object
- #redis_servers ⇒ Object
-
#standalone ⇒ Object
writeonly
Sets the attribute standalone.
Instance Method Summary collapse
- #do_not_load_root_schedule? ⇒ Boolean
- #fire_around_callback(name, job, calls = , &block) ⇒ Object
- #fire_callback(name, *args) ⇒ Object
- #logger? ⇒ Boolean
- #paths ⇒ Object
- #register_callback(name, &block) ⇒ Object
- #standalone? ⇒ Boolean
Instance Attribute Details
#do_not_load_root_schedule=(value) ⇒ Object (writeonly)
Sets the attribute do_not_load_root_schedule
7 8 9 |
# File 'lib/schked/config.rb', line 7 def do_not_load_root_schedule=(value) @do_not_load_root_schedule = value end |
#logger ⇒ Object
20 21 22 |
# File 'lib/schked/config.rb', line 20 def logger @logger ||= Logger.new($stdout).tap { |l| l.level = Logger::INFO } end |
#redis_servers ⇒ Object
51 52 53 |
# File 'lib/schked/config.rb', line 51 def redis_servers @redis_servers ||= [ENV.fetch("REDIS_URL", "redis://127.0.0.1:6379")] end |
#standalone=(value) ⇒ Object (writeonly)
Sets the attribute standalone
7 8 9 |
# File 'lib/schked/config.rb', line 7 def standalone=(value) @standalone = value end |
Instance Method Details
#do_not_load_root_schedule? ⇒ Boolean
24 25 26 |
# File 'lib/schked/config.rb', line 24 def do_not_load_root_schedule? !!@do_not_load_root_schedule end |
#fire_around_callback(name, job, calls = , &block) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/schked/config.rb', line 38 def fire_around_callback(name, job, calls = callbacks[name], &block) return yield if calls.none? calls.first.call(job) do calls = calls.drop(1) if calls.any? fire_around_callback(name, job, calls, &block) else yield end end end |
#fire_callback(name, *args) ⇒ Object
32 33 34 35 36 |
# File 'lib/schked/config.rb', line 32 def fire_callback(name, *args) callbacks[name].each do |callback| callback.call(*args) end end |
#logger? ⇒ Boolean
16 17 18 |
# File 'lib/schked/config.rb', line 16 def logger? !!@logger end |
#paths ⇒ Object
12 13 14 |
# File 'lib/schked/config.rb', line 12 def paths @paths ||= [] end |
#register_callback(name, &block) ⇒ Object
28 29 30 |
# File 'lib/schked/config.rb', line 28 def register_callback(name, &block) callbacks[name] << block end |
#standalone? ⇒ Boolean
55 56 57 58 59 |
# File 'lib/schked/config.rb', line 55 def standalone? @standalone = ENV["RAILS_ENV"] == "test" || ENV["RACK_ENV"] == "test" if @standalone.nil? !!@standalone end |