Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
default_field command means when you assign to a field that's a struc…
…ture, the assignment proxies to that field, which is way more useful than I'm making it sound
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Ruckus | ||
module StructureSearchModules | ||
def self.included(klass) | ||
klass.class_eval { | ||
class_inheritable_array :search_modules | ||
write_inheritable_array :search_modules, [] | ||
} | ||
|
||
klass.extend(ClassMethods) | ||
end | ||
|
||
module ClassMethods | ||
def derive_search_module | ||
if self.search_modules.empty? | ||
return Ruckus | ||
else | ||
mod = Module.new | ||
self.search_modules.each do |m| | ||
mod.module_eval "include #{ m.to_s.class_name }" | ||
end | ||
mod.module_eval "include Ruckus" | ||
return mod | ||
end | ||
end | ||
|
||
def search_module(*args) | ||
args.each do |m| | ||
self.search_modules << m | ||
end | ||
end | ||
end | ||
end | ||
end |