Sha256: 6658b5f8f05642d4b99f135bec6ba4381fd9282d4c20fa89a575abe19ba21912

Contents?: true

Size: 897 Bytes

Versions: 1

Compression:

Stored size: 897 Bytes

Contents

module Fume
  module Searchlogic

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

    module SearchExtensions
      module ClassMethods
        def human_name
          "Search"
        end
      end
      
      module InstanceMethods
        extend ClassMethods
        
        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

1 entries across 1 versions & 1 rubygems

Version Path
fume-0.2.5 lib/fume/searchlogic.rb