Skip to content

Instantly share code, notes, and snippets.

@pat
Created September 4, 2009 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pat/181000 to your computer and use it in GitHub Desktop.
Save pat/181000 to your computer and use it in GitHub Desktop.
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