Sha256: 70a46b6bf7fed893cf025ec44625a8f2adf0d3a1af1a3692ecd519d5025c03c4

Contents?: true

Size: 940 Bytes

Versions: 3

Compression:

Stored size: 940 Bytes

Contents

module Fume
  module Searchlogic

    def self.try_enable
      if defined? ::Searchlogic
        ActionController::Base.send :helper, RailsHelpers
        ::Searchlogic::Search.send :include, SearchExtensions::InstanceMethods
        ::Searchlogic::Search.send :extend, SearchExtensions::ClassMethods
      end
    end

    module SearchExtensions
      module ClassMethods
        def human_name
          "Search"
        end
      end
      
      module InstanceMethods

        def human_attribute_name(name)
          klass.human_attribute_name(name)
        end
        
        def new_record?
          true
        end
      end
    end

    module RailsHelpers
      def i18n_order(search, options = {}, html_options = {})
        attribute_name = options[:attr] || options[:by]
        options[:as] ||= translate_attribute(search.klass, attribute_name)
        order(search, options, html_options)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fume-0.3.2 lib/fume/searchlogic.rb
fume-0.3.1 lib/fume/searchlogic.rb
fume-0.3.0 lib/fume/searchlogic.rb