Class: Schked::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/schked/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#do_not_load_root_schedule=(value) ⇒ Object (writeonly)

Sets the attribute do_not_load_root_schedule

Parameters:

  • value

    the value to set the attribute do_not_load_root_schedule to.



7
8
9
# File 'lib/schked/config.rb', line 7

def do_not_load_root_schedule=(value)
  @do_not_load_root_schedule = value
end

#loggerObject



20
21
22
# File 'lib/schked/config.rb', line 20

def logger
  @logger ||= Logger.new($stdout).tap { |l| l.level = Logger::INFO }
end

#redis_serversObject



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

Parameters:

  • value

    the value to set the attribute standalone to.



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

Returns:

  • (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

Returns:

  • (Boolean)


16
17
18
# File 'lib/schked/config.rb', line 16

def logger?
  !!@logger
end

#pathsObject



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

Returns:

  • (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