Class: Inprovise::Infrastructure::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/inprovise/infra.rb

Direct Known Subclasses

Group, Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, config = {}) ⇒ Target

Returns a new instance of Target.



80
81
82
83
84
# File 'lib/inprovise/infra.rb', line 80

def initialize(name, config = {})
  @name = name
  @config = config
  Inprovise::Infrastructure.register(self)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



78
79
80
# File 'lib/inprovise/infra.rb', line 78

def config
  @config
end

#nameObject (readonly)

Returns the value of attribute name.



78
79
80
# File 'lib/inprovise/infra.rb', line 78

def name
  @name
end

Instance Method Details

#add_target(tgt) ⇒ Object

Raises:

  • (RuntimeError)


102
103
104
# File 'lib/inprovise/infra.rb', line 102

def add_target(tgt)
  raise RuntimeError, "Cannot add #{tgt.to_s} to #{self.to_s}"
end

#add_to(grp) ⇒ Object



94
95
96
# File 'lib/inprovise/infra.rb', line 94

def add_to(grp)
  grp.add_target(self)
end

#get(option) ⇒ Object



86
87
88
# File 'lib/inprovise/infra.rb', line 86

def get(option)
  config[option]
end

#includes?(tgt) ⇒ Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/inprovise/infra.rb', line 110

def includes?(tgt)
  false
end

#remove_from(grp) ⇒ Object



98
99
100
# File 'lib/inprovise/infra.rb', line 98

def remove_from(grp)
  grp.remove_target(self)
end

#remove_target(tgt) ⇒ Object



106
107
108
# File 'lib/inprovise/infra.rb', line 106

def remove_target(tgt)
  # ignore
end

#set(option, value) ⇒ Object



90
91
92
# File 'lib/inprovise/infra.rb', line 90

def set(option, value)
  config[option.to_sym] = value
end

#targetsObject



114
115
116
# File 'lib/inprovise/infra.rb', line 114

def targets
  [self]
end

#targets_with_configObject



118
119
120
# File 'lib/inprovise/infra.rb', line 118

def targets_with_config
  {self => @config.dup}
end