Class: Threatinator::Config::Base

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

Class Method Summary collapse

Class Method Details

.properties(namespace = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/threatinator/config/base.rb', line 7

def self.properties(namespace = nil)
  ret = {}
  self.attribute_set.each do |attribute|
    name = attribute.name.to_s
    unless namespace.nil?
      name = [namespace, name].join('.')
    end

    if attribute.primitive.ancestors.include?(Threatinator::Config::Base)
      ret.merge!(attribute.primitive.properties(name))
      next
    end

    desc = attribute.options[:description]
    case desc
    when nil
      next
    when ::Proc
      desc = desc.call(self, attribute)
    end 
    ret[name] = [desc, attribute.type]
  end
  ret
end