Method: Wukong::Processor.configure

Defined in:
lib/wukong/processor.rb

.configure(settings) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/wukong/processor.rb', line 47

def configure(settings)
  settings.description = description if description
  fields.each_pair do |name, field|
    next if field.doc == false || field.doc.to_s == 'false'
    next if [:log, :notifier].include?(name)
    field_props = {}.tap do |props|
      props[:description] = field.doc unless field.doc == "#{name} field"
      field_type = (field.type.respond_to?(:product) ? field.type.product : field.type)
      configliere_type = case field_type
      when String                then nil
      when TrueClass, FalseClass then :boolean
      else field_type
      end
      
      props[:type]        = configliere_type if configliere_type
      props[:default]     = field.default if field.default
    end
    existing_value = settings[name]
    settings.define(name, field_props)
    settings[name] = existing_value unless existing_value.nil?
  end
end