Class: Swiftly::Resolver

Inherits:
Object
  • Object
show all
Defined in:
lib/swiftly/resolver.rb

Constant Summary collapse

@@settings =
{
  server: [],
}

Class Method Summary collapse

Class Method Details

.get(setting) ⇒ Object



13
14
15
16
17
18
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/swiftly/resolver.rb', line 13

def self.get setting

  override  = {}
  final     = {}

  # Check to see if there is a setting in the array
  # that matches the setting param
  if !@@settings[setting].nil?

    # If so loop through
    @@settings[setting].each do |s|

      s.each do |k, v|

        override[k] = []

      end
    end

    @@settings[setting].each do |s|

      s.each do |k, v|

        override[k] << v

      end
    end

    override.each do |k, v|

      construct = {}
      capture   = {}
      override[k].each do |o|

        final.merge!( {k => {} } )

        available_methods = o.methods - Object.methods

        available_methods.each_with_index do |n, e|

          unless (n.to_s.end_with?("="))

            construct[n] = o.send(n)  unless o.send(n).nil?

          end

        end

        final[k] = capture.merge!( construct )

      end
    end
  end

  final

end

.load(setting, type, attributes) ⇒ Object



8
9
10
11
# File 'lib/swiftly/resolver.rb', line 8

def self.load setting, type, attributes

  @@settings[setting] <<  { type => attributes }
end