Method: Configatron::Store#inspect

Defined in:
lib/gems/configatron-2.2.2/lib/configatron/store.rb

#inspectObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/gems/configatron-2.2.2/lib/configatron/store.rb', line 19

def inspect
  path = [@_name]
  parent = @_parent
  until parent.nil?
    path << parent.instance_variable_get('@_name')
    parent = parent.instance_variable_get('@_parent')
  end
  path << 'configatron'
  path.compact!
  path.reverse!
  f_out = []
  @_store.each do |k, v|
    if v.is_a?(Configatron::Store)
      v.inspect.each_line do |line|
        if line.match(/\n/)
          line.each_line do |l|
            l.strip!
            f_out << l
          end
        else
          line.strip!
          f_out << line
        end
      end
    else
      f_out << "#{path.join('.')}.#{k} = #{v.inspect}"
    end
  end
  f_out.compact.sort.join("\n")
end