Sha256: 7a8ac2b41d820bfe5a7af7d9bb31af2f9a3affb2f63a240457a259c8dc05b347

Contents?: true

Size: 1.95 KB

Versions: 51

Compression:

Stored size: 1.95 KB

Contents

module ActsAsSolr #:nodoc:
  
  class Post
    def initialize(body, mode = :search)
      @body = body
      @mode = mode
      puts "The method ActsAsSolr::Post.new(body, mode).execute_post is depracated. " +
           "Use ActsAsSolr::Post.execute(body, mode) instead!"
    end
    
    def execute_post
      ActsAsSolr::Post.execute(@body, @mode)
    end    
  end
  
  module ClassMethods
    def find_with_facet(query, options={})
      Deprecation.plog "The method find_with_facet is deprecated. Use find_by_solr instead, passing the " +
                       "arguments the same way you used to do with find_with_facet."
      find_by_solr(query, options)
    end
  end
  
  class Deprecation
    # Validates the options passed during query
    def self.validate_query options={}
      if options[:field_types]
        plog "The option :field_types for searching is deprecated. " +
             "The field types are automatically traced back when you specify a field type in your model."
      end
      if options[:sort_by]
        plog "The option :sort_by is deprecated, use :order instead!"
        options[:order] ||= options[:sort_by]
      end
      if options[:start]
        plog "The option :start is deprecated, use :offset instead!"
        options[:offset] ||= options[:start]
      end
      if options[:rows]
        plog "The option :rows is deprecated, use :limit instead!"
        options[:limit] ||= options[:rows]
      end
    end
    
    # Validates the options passed during indexing
    def self.validate_index options={}
      if options[:background]
        plog "The :background option is being deprecated. There are better and more efficient " +
             "ways to handle delayed saving of your records."
      end
    end
    
    # This will print the text to stdout and log the text
    # if rails logger is available
    def self.plog text
      puts text
      RAILS_DEFAULT_LOGGER.warn text if defined? RAILS_DEFAULT_LOGGER
    end
  end
  
end

Version data entries

51 entries across 51 versions & 9 rubygems

Version Path
honkster-acts_as_solr-0.1.0 lib/acts_as_solr/deprecation.rb
honkster-acts_as_solr-0.2.0 lib/acts_as_solr/deprecation.rb
honkster-acts_as_solr-0.2.1 lib/acts_as_solr/deprecation.rb
honkster-acts_as_solr-0.2.2 lib/acts_as_solr/deprecation.rb
honkster-acts_as_solr-0.2.3 lib/acts_as_solr/deprecation.rb
honkster-acts_as_solr-0.2.4 lib/acts_as_solr/deprecation.rb
honkster-acts_as_solr-0.2.5 lib/acts_as_solr/deprecation.rb
honkster-acts_as_solr-0.3.4 lib/acts_as_solr/deprecation.rb
jbasdf-acts_as_solr-0.3.3 lib/acts_as_solr/deprecation.rb
jbasdf-jbasdf-acts_as_solr-0.4.0 lib/acts_as_solr/deprecation.rb
jbasdf-muck-solr-0.4.0 lib/acts_as_solr/deprecation.rb
jbasdf-muck-solr-0.4.1 lib/acts_as_solr/deprecation.rb
jbasdf-muck-solr-0.4.2 lib/acts_as_solr/deprecation.rb
onemorecloud-websolr-rails-1.1.1 lib/deprecation.rb
onemorecloud-websolr-rails-1.3.3 lib/deprecation.rb
onemorecloud-websolr-rails-1.4.0 lib/deprecation.rb
onemorecloud-websolr-rails-1.4.1 lib/deprecation.rb
acts_as_solr_reloaded-1.6.0 lib/acts_as_solr/deprecation.rb
muck-solr-3.0.1 lib/acts_as_solr/deprecation.rb
muck-solr-3.0.0 lib/acts_as_solr/deprecation.rb