Class: Inprovise::Infrastructure::Target
- Inherits:
-
Object
- Object
- Inprovise::Infrastructure::Target
- Defined in:
- lib/inprovise/infra.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #add_target(tgt) ⇒ Object
- #add_to(grp) ⇒ Object
- #get(option) ⇒ Object
- #includes?(tgt) ⇒ Boolean
-
#initialize(name, config = {}) ⇒ Target
constructor
A new instance of Target.
- #remove_from(grp) ⇒ Object
- #remove_target(tgt) ⇒ Object
- #set(option, value) ⇒ Object
- #targets ⇒ Object
- #targets_with_config ⇒ Object
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
#config ⇒ Object (readonly)
Returns the value of attribute config.
78 79 80 |
# File 'lib/inprovise/infra.rb', line 78 def config @config end |
#name ⇒ Object (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
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
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 |
#targets ⇒ Object
114 115 116 |
# File 'lib/inprovise/infra.rb', line 114 def targets [self] end |
#targets_with_config ⇒ Object
118 119 120 |
# File 'lib/inprovise/infra.rb', line 118 def targets_with_config {self => @config.dup} end |