Sha256: 95418ce0dbca1a9eaad4ca1867d4e13a34b9c209ee1ef08bf60acefcb89e0dc1

Contents?: true

Size: 1.11 KB

Versions: 17

Compression:

Stored size: 1.11 KB

Contents

module Elastics
  module ActiveModel

    attr_reader :_version, :_id, :highlight
    alias_method :id, :_id

    def self.included(base)
      base.class_eval do
        @elastics ||= ClassProxy::Base.new(base)
        @elastics.extend(ClassProxy::ModelSyncer)
        @elastics.extend(ClassProxy::ModelIndexer).init
        @elastics.extend(ClassProxy::ActiveModel).init :params => {:version => true}
        def self.elastics; @elastics end
        elastics.synced = [self]

        include Scopes
        include ActiveAttr::Model

        extend  ::ActiveModel::Callbacks
        define_model_callbacks :create, :update, :save, :destroy

        include Storage::InstanceMethods
        extend  Storage::ClassMethods
        include Inspection
        extend  Timestamps
        extend  Attachment
      end
    end

    def elastics
      @elastics ||= InstanceProxy::ActiveModel.new(self)
    end

    def elastics_source
      attributes
    end

    def elastics_indexable?
      true
    end

    def method_missing(meth, *args, &block)
      raw_document.respond_to?(meth) ? raw_document.send(meth) : super
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
elastics-models-1.1.9 lib/elastics/active_model.rb
elastics-models-1.1.8 lib/elastics/active_model.rb
elastics-models-1.1.7 lib/elastics/active_model.rb
elastics-models-1.1.6 lib/elastics/active_model.rb
elastics-models-1.1.5 lib/elastics/active_model.rb
elastics-models-1.1.4 lib/elastics/active_model.rb
elastics-models-1.1.3 lib/elastics/active_model.rb
elastics-models-1.1.2 lib/elastics/active_model.rb
elastics-models-1.1.1 lib/elastics/active_model.rb
elastics-models-1.1.0 lib/elastics/active_model.rb
elastics-models-1.0.10 lib/elastics/active_model.rb
elastics-models-1.0.9 lib/elastics/active_model.rb
elastics-models-1.0.8 lib/elastics/active_model.rb
elastics-models-1.0.7 lib/elastics/active_model.rb
elastics-models-1.0.6 lib/elastics/active_model.rb
elastics-models-1.0.5 lib/elastics/active_model.rb
elastics-models-1.0.4 lib/elastics/active_model.rb