module Bondo
Usage
require 'bondo' class Bar def start end end class Baz def eject end end class Foo < SomeClass include Bondo def initialize bondo_add Bar.new bondo_add Baz.new end end f = Foo.new f.stop f.eject
Constants
- VERSION
Public Instance Methods
bondo_add(*children)
click to toggle source
# File lib/bondo.rb, line 33 def bondo_add(*children) children.each { |child| bondo_children.unshift child } unless bondo_has_all?(*children) end
bondo_children()
click to toggle source
# File lib/bondo.rb, line 29 def bondo_children @bondo_children ||= [] end
bondo_has?(child)
click to toggle source
# File lib/bondo.rb, line 41 def bondo_has?(child) bondo_children.include? child end
bondo_has_all?(*children)
click to toggle source
# File lib/bondo.rb, line 37 def bondo_has_all?(*children) children.all? { |child| bondo_has? child } end
bondo_remove(child)
click to toggle source
# File lib/bondo.rb, line 45 def bondo_remove(child) bondo_children.delete child if bondo_has? child end
method_missing(symbol_or_string, *args, &block)
click to toggle source
Calls superclass method
# File lib/bondo.rb, line 53 def method_missing(symbol_or_string, *args, &block) if respond_to_missing?(symbol_or_string, false) bondo_children.map { |x| return x.send(symbol_or_string, *args, &block) if x.respond_to? symbol_or_string } end super end
respond_to_missing?(symbol_or_string, include_all)
click to toggle source
Calls superclass method
# File lib/bondo.rb, line 49 def respond_to_missing?(symbol_or_string, include_all) bondo_children.map { |x| x.respond_to? symbol_or_string, include_all }.any? || super end