#coding=utf-8 # elasticsearch 在开发环境下也要打开,很烦人的 if Rails.env.development? require 'elasticsearch/model' module Elasticsearch module Model class NoObject instance_methods.each do |m| undef_method(m) unless [:object_id, :__send__, :undef_method, :method_missing].include?(m) end def method_missing(method, *args, &block) puts "NoObject #{method} #{args}" end def NoObject.included(mod) puts "#{self} included in #{mod}" end def self.extended(mod) puts "#{self} extended in #{mod}" end def initialize puts methods end end def self.included(base) base.instance_eval do def settings(a) end def __elasticsearch__ @__elasticsearch__ ||= NoObject.new end end base.class_eval do def __elasticsearch__ @__elasticsearch__ ||= NoObject.new end end end end end end