Class: Harmoniser::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/harmoniser/options.rb

Constant Summary collapse

DEFAULT =
{
  concurrency: -> { Float::INFINITY },
  environment: -> { ENV.fetch("RAILS_ENV", ENV.fetch("RACK_ENV", "production")) },
  require: -> { "." },
  timeout: -> { 25 },
  verbose: -> { false }
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ Options

Returns a new instance of Options.



11
12
13
14
15
16
17
# File 'lib/harmoniser/options.rb', line 11

def initialize(**kwargs)
  options = DEFAULT
    .map { |k, v| [k, v.call] }
    .to_h
    .merge(kwargs)
  super(**options)
end

Instance Method Details

#production?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/harmoniser/options.rb', line 19

def production?
  environment == "production"
end

#unbounded_concurrency?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/harmoniser/options.rb', line 23

def unbounded_concurrency?
  concurrency == Float::INFINITY
end

#verbose?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/harmoniser/options.rb', line 27

def verbose?
  !!verbose
end