2016-01-29 20:31:25 +08:00
|
|
|
#coding=utf-8
|
|
|
|
|
|
|
|
# elasticsearch 在开发环境下也要打开,很烦人的
|
|
|
|
|
|
|
|
if Rails.env.development?
|
|
|
|
|
|
|
|
require 'elasticsearch/model'
|
|
|
|
module Elasticsearch
|
|
|
|
module Model
|
|
|
|
class NoObject
|
|
|
|
|
|
|
|
instance_methods.each do |m|
|
2016-02-02 12:40:00 +08:00
|
|
|
undef_method(m) unless [:object_id, :__send__, :undef_method, :method_missing].include?(m)
|
2016-01-29 20:31:25 +08:00
|
|
|
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
|
|
|
|
|
2016-02-02 12:40:00 +08:00
|
|
|
end
|