Module: ParamsProcessor

Included in:
Gossamer::Broker, Gossamer::Resource
Defined in:
lib/gossamer/params_processor.rb

Instance Method Summary collapse

Instance Method Details

#process_params(params = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/gossamer/params_processor.rb', line 3

def process_params(params={})
  if (required = params.delete(:REQUIRED))
    required.each { |name| raise "#{name.inspect} required" unless params[name] }
  end

  if (defaults = params.delete(:DEFAULTS))
    defaults.each { |name, value| params[name] ||= value }
  end

  config = params.delete(:CONFIG) || []
  params.each { |name, value| method("#{name}=").call(value) unless config.include?(name) }
end