Class: ClassifyCluster::Configurator::Role

Inherits:
Object
  • Object
show all
Defined in:
lib/classify_cluster/configurator/role.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, type, options = {}, &block) ⇒ Role

Returns a new instance of Role.



27
28
29
30
31
32
33
34
# File 'lib/classify_cluster/configurator/role.rb', line 27

def initialize(node, type, options={}, &block)
  @type = type
  @options = HashWithIndifferentAccess.new(options)
  @node = node
  @variables = {}
  block.call(self) if block_given?
  self.send("after_#{@type}_role_assignment".to_sym)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object (private)



111
112
113
114
# File 'lib/classify_cluster/configurator/role.rb', line 111

def method_missing(method_name, *args)
  add_klass_from_role
  add_variable_from_role
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



26
27
28
# File 'lib/classify_cluster/configurator/role.rb', line 26

def node
  @node
end

#options(value = nil) ⇒ Object (readonly)

Returns the value of attribute options.



26
27
28
# File 'lib/classify_cluster/configurator/role.rb', line 26

def options
  @options
end

#type(value = nil) ⇒ Object (readonly)

Returns the value of attribute type.



26
27
28
# File 'lib/classify_cluster/configurator/role.rb', line 26

def type
  @type
end

#variablesObject (readonly)

Returns the value of attribute variables.



26
27
28
# File 'lib/classify_cluster/configurator/role.rb', line 26

def variables
  @variables
end

Instance Method Details

#variable(name, value) ⇒ Object



43
44
45
46
# File 'lib/classify_cluster/configurator/role.rb', line 43

def variable(name, value)
  @variables[name] = value
  @node.variable name, value
end