Created
September 4, 2009 17:35
-
-
Save pat/181000 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
module ThinkingSphinx | |
class Search | |
# rough implementation of what the code actually does. | |
CoreMethods = %w( == class class_eval extend frozen? id instance_eval | |
instance_of? instance_values instance_variable_defined? | |
instance_variable_get instance_variable_set instance_variables is_a? | |
kind_of? member? method methods nil? object_id respond_to? send should | |
type ) | |
instance_methods.select { |method| | |
method.to_s[/^__/].nil? && !CoreMethods.include?(method.to_s) | |
}.each { |method| | |
undef_method method | |
} | |
def initialize | |
@array = [] | |
end | |
def method_missing(method, *args, &block) | |
# custom checks | |
array.send(method, *args, &block) | |
end | |
end | |
end | |
Array === ThinkingSphinx::Search.new #=> false | |
# How can I make this return true, without being a subclass of Array? | |
# You cannot change the test, because the comparison is being made by Rails, and | |
# I don't want to hack Rails internals to make this work. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment