Module: Lycra::Document::Proxy

Defined in:
lib/lycra/document/proxy.rb

Defined Under Namespace

Modules: BaseProxy, ClassMethods, InstanceMethods Classes: ClassProxy, InstanceProxy

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/lycra/document/proxy.rb', line 6

def self.included(base)
  base.send :extend,  ClassMethods
  base.send :include, InstanceMethods

  base.class_eval do
    def self.__lycra__(&block)
      @__lycra__ ||= ClassProxy.new(self)
      @__lycra__.instance_eval(&block) if block_given?
      @__lycra__
    end

    def __lycra__(&block)
      @__lycra__ ||= InstanceProxy.new(self)
      @__lycra__.instance_eval(&block) if block_given?
      @__lycra__
    end

    self.__lycra__.class_eval do
      include  ::Elasticsearch::Model::Importing::ClassMethods
      include  ::Elasticsearch::Model::Adapter.from_class(base).importing_mixin
    end

    Registry.add(base)
  end
end