Sha256: 99b7e24e8e6608058ea5967b2a0fe279afb4493c18355aff1bd0ec84268ccf03

Contents?: true

Size: 1.07 KB

Versions: 25

Compression:

Stored size: 1.07 KB

Contents

module Elastics
  module InstanceProxy
    class ActiveModel < ModelIndexer

      def store(*vars)
        return super unless instance.elastics_indexable? # this should never happen since elastics_indexable? returns true
        meth = (id.nil? || id.empty?) ? :post_store : :put_store
        Elastics.send(meth, metainfo, {:data => instance.elastics_source}, *vars)
      end

      def sync_self
        instance.instance_eval do
          if destroyed?
            if @skip_destroy_callbacks
              elastics.remove
            else
              run_callbacks :destroy do
                elastics.remove
              end
            end
          else
            run_callbacks :save do
              context = new_record? ? :create : :update
              run_callbacks(context) do
                result    = context == :create ? elastics.store : elastics.store(:params => { :version => _version })
                @_id      = result['_id']
                @_version = result['_version']
              end
            end
          end
        end
      end

    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
elastics-models-1.3.3 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.3.2 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.3.1 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.3.0 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.2.1 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.2.0 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.1.11 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.1.10 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.1.9 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.1.8 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.1.7 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.1.6 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.1.5 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.1.4 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.1.3 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.1.2 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.1.1 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.1.0 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.0.10 lib/elastics/instance_proxy/active_model.rb
elastics-models-1.0.9 lib/elastics/instance_proxy/active_model.rb