Sha256: 598f6c0be5136e975a3e21204883f03fd1adfd2c63b4ce5fb6205f9617768630

Contents?: true

Size: 804 Bytes

Versions: 3

Compression:

Stored size: 804 Bytes

Contents

module Spotlight::SolrDocument::ActiveModelConcern
  extend ActiveSupport::Concern
  
  included do
    include Spotlight::ArLight
    extend ActiveModel::Callbacks
    define_model_callbacks :save
  end
  
  module ClassMethods

    # needed for Rails 4.1 + act_as_taggable
    def dangerous_attribute_method? *args
      false
    end
    
    # needed for Rails 4.1 + act_as_taggable
    def generated_association_methods
      @generated_association_methods ||= begin
        mod = const_set(:GeneratedAssociationMethods, Module.new)
        include mod
        mod
      end
    end
  end
  
  def save
    run_callbacks :save do
      # no-op
    end
  end

  def to_key
    [id]
  end

  def persisted?
    true
  end

  def destroyed?
    false
  end

  def new_record?
    !persisted?
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-spotlight-0.4.1 app/models/concerns/spotlight/solr_document/active_model_concern.rb
blacklight-spotlight-0.3.1 app/models/concerns/spotlight/solr_document/active_model_concern.rb
blacklight-spotlight-0.3.0 app/models/concerns/spotlight/solr_document/active_model_concern.rb