Module: Train::Platforms::Common
Instance Method Summary collapse
- #detect(&block) ⇒ Object
-
#in_family(family) ⇒ Object
Add a family connection.
- #inspect ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#detect(&block) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/train/platforms/common.rb', line 19 def detect(&block) @detect = block if block # TODO: detect shouldn't be a setter and getter at the same time @detect ||= ->(_) { false } end |
#in_family(family) ⇒ Object
Add a family connection. This will create a family if it does not exist and add a child relationship.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/train/platforms/common.rb', line 5 def in_family(family) if self.class == Train::Platforms::Family && @name == family raise "Unable to add family #{@name} to itself: '#{@name}.in_family(#{family})'" end # add family to the family list family = Train::Platforms.family(family) family.children[self] = @condition @families[family] = @condition @condition = nil self end |
#inspect ⇒ Object
31 32 33 |
# File 'lib/train/platforms/common.rb', line 31 def inspect to_s end |
#to_s ⇒ Object
26 27 28 29 |
# File 'lib/train/platforms/common.rb', line 26 def to_s be = backend ? backend.backend_type : "unknown" "%s:%s:%s" % [self.class, be, name] end |