blob: d926ee2b986bc18bd3ba94b317da038f5eb77d95 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
module Oxidized::Config::Vars
# convenience method for accessing node, group or global level user variables
# nil values will be ignored
def vars name
r = @node.vars[name] unless @node.vars.nil?
if Oxidized.config.groups.has_key?(@node.group)
if Oxidized.config.groups[@node.group].vars.has_key?(name.to_s)
r ||= Oxidized.config.groups[@node.group].vars[name.to_s]
end
end
if Oxidized.config.models.has_key?(@node.model.class.name.to_s.downcase)
if Oxidized.config.models[@node.model.class.name.to_s.downcase].vars.has_key?(name.to_s)
r ||= Oxidized.config.models[@node.model.class.name.to_s.downcase].vars[name.to_s]
end
end
r ||= Oxidized.config.vars[name.to_s] if Oxidized.config.vars.has_key?(name.to_s)
r
end
end
|