Created
December 17, 2010 20:43
-
-
Save brianhempel/745675 to your computer and use it in GitHub Desktop.
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
class Person | |
include MongoMapper::Document | |
end | |
class Registree < Person | |
key :in_wels, Boolean | |
key :in_vienna, Boolean | |
end | |
class Visitor | |
QUERY = { "$or" => [{:in_wels => true}, {:in_vienna => true}] } | |
def self.find(*args) | |
Array(Registree.where(QUERY).find(*args).all).map do |registree| | |
self.new(registree) | |
end | |
end | |
instance_methods.each do |m| | |
undef_method m unless m =~ /(^__|^object_id$)/ | |
end | |
attr_accessor :real | |
def initialize(*args) | |
if args[0].is_a? Registree | |
@real = args[0] | |
else | |
@real = Registree.new(*args) | |
end | |
super() | |
end | |
protected | |
def method_missing(method, *args, &block) | |
real.send(method, *args, &block) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment