module Oni::Configurable::ClassMethods

Public Instance Methods

options() click to toggle source

Returns a Hash containing the options of the current class.

@return [Hash]

# File lib/oni/configurable.rb, line 67
def options
  return @options ||= {}
end
set(option, value) click to toggle source

Sets the option to the given value. If a Proc (or any object that responds to `#call`) is given it's not evaluated until it's accessed. This makes it possible to for example set a logger that's not created until an instance of the including class is created.

@example Setting a regular option

set :number, 10

@example Setting an option using a proc

# This means the logger won't be shared between different instances of
# the including class.
set :logger, proc { Logger.new(STDOUT) }

@param [Symbol|String] option @param [Mixed] value

# File lib/oni/configurable.rb, line 88
def set(option, value)
  options[option.to_sym] = value
end
set_multiple(options) click to toggle source

Sets a number of options based on the given Hash.

@example

set_multiple(:a => 10, :b => 20)

@param [Hash] options

# File lib/oni/configurable.rb, line 100
def set_multiple(options)
  options.each do |option, value|
    set(option, value)
  end
end