Sha256: 30a44f4aceedcbe737f8235f93249532962c020cf1f5545a3c6097dbf2c86f64

Contents?: true

Size: 858 Bytes

Versions: 13

Compression:

Stored size: 858 Bytes

Contents

module Highrise
  module Searchable
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      # List By Search Criteria
      # Ex: Highrise::Person.search(:email => "john.doe@example.com", :country => "CA")
      # Available criteria are: city, state, country, zip, phone, email
      def search(options = {})
        search_params = options.inject({}) { |h, (k, v)| h["criteria[#{k}]"] = v; h }
        # This might have to be changed in the future if other non-pagable resources become searchable
        if self.respond_to?(:find_all_across_pages)
          self.find_all_across_pages(:from => "/#{self.collection_name}/search.xml", :params => search_params)
        else
          self.find(:all, {:from => "/#{self.collection_name}/search.xml", :params => search_params})
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
highrise-3.2.3 lib/highrise/searchable.rb
highrise-3.2.1 lib/highrise/searchable.rb
highrise-3.1.6 lib/highrise/searchable.rb
highrise-3.1.5 lib/highrise/searchable.rb
highrise-3.1.2 lib/highrise/searchable.rb
highrise-3.1.1 lib/highrise/searchable.rb
highrise-3.1.0 lib/highrise/searchable.rb
highrise-3.1.0.pre lib/highrise/searchable.rb
highrise-3.0.5 lib/highrise/searchable.rb
highrise-3.0.4 lib/highrise/searchable.rb
highrise-3.0.3 lib/highrise/searchable.rb
highrise-3.0.1 lib/highrise/searchable.rb
highrise-3.0.0 lib/highrise/searchable.rb