Sha256: a86b4f575186801a0c718bfc351c2d3c1a77d0b21983e4c76b1901b47aced304

Contents?: true

Size: 443 Bytes

Versions: 4

Compression:

Stored size: 443 Bytes

Contents

module Pollyanna
  module Searchable

    def self.included(klass)
      klass.class_eval do
        before_save :set_search_text
        # Use Proc.new so the number of arguments does not matter
        named_scope :search, Proc.new { |query, options| Search.new(query, table_name).scope_options(options) }
      end
    end
    
    def set_search_text
      self.search_text = search_text if respond_to?(:"search_text=")
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pollyanna-1.0.3 lib/pollyanna/searchable.rb
pollyanna-1.0.2 lib/pollyanna/searchable.rb
pollyanna-1.0.1 lib/pollyanna/searchable.rb
pollyanna-1.0.0 lib/pollyanna/searchable.rb