Skip to content

Instantly share code, notes, and snippets.

@cheeyeo
Created March 19, 2014 13:58
Show Gist options
  • Save cheeyeo/9642179 to your computer and use it in GitHub Desktop.
Save cheeyeo/9642179 to your computer and use it in GitHub Desktop.
Ruby: calling included classes within parent module
module Search
@children = []
def self.included(base)
@children << base
end
def self.query(val)
@children.each do |child|
child.query(val)
end
end
end
class A
include Search
def self.query(val)
p "Calling query A - with #{val}"
end
end
class B
include Search
def self.query(val)
p "Caling query B - with #{val}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment