Sha256: 387c1318ad59f86cd668ec88c56e8151680012d939a2d0e8766e142d3baeb380

Contents?: true

Size: 1.94 KB

Versions: 13

Compression:

Stored size: 1.94 KB

Contents

module ActiveScaffold::Config
  class Search < Base
    self.crud_type = :read

    def initialize(core_config)
      super
      @text_search = self.class.text_search
      @live = self.class.live?
      @split_terms = self.class.split_terms
    end


    # global level configuration
    # --------------------------
    # the ActionLink for this action
    cattr_accessor :link
    @@link = ActiveScaffold::DataStructures::ActionLink.new('show_search', :label => :search, :type => :collection, :security_method => :search_authorized?, :ignore_method => :search_ignore?)

    # A flag for how the search should do full-text searching in the database:
    # * :full: LIKE %?%
    # * :start: LIKE ?%
    # * :end: LIKE %?
    # * false: LIKE ?
    # Default is :full
    cattr_accessor :text_search
    @@text_search = :full

    # whether submits the search as you type
    cattr_writer :live
    def self.live?
      @@live
    end

    cattr_accessor :split_terms
    @@split_terms = " "

    # instance-level configuration
    # ----------------------------

    # provides access to the list of columns specifically meant for the Search to use
    def columns
      # we want to delay initializing to the @core.columns set for as long as possible. Too soon and .search_sql will not be available to .searchable?
      unless @columns
        self.columns = @core.columns.collect{|c| c.name if @core.columns._inheritable.include?(c.name) and c.searchable? and c.association.nil? and c.text?}.compact
      end
      @columns
    end

    public :columns=

    # A flag for how the search should do full-text searching in the database:
    # * :full: LIKE %?%
    # * :start: LIKE ?%
    # * :end: LIKE %?
    # * false: LIKE ?
    # Default is :full
    attr_accessor :text_search

    attr_accessor :split_terms

    # the ActionLink for this action
    attr_accessor :link

    # whether submits the search as you type
    attr_writer :live
    def live?
      @live
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
active_scaffold-3.4.17 lib/active_scaffold/config/search.rb
active_scaffold-3.4.16 lib/active_scaffold/config/search.rb
active_scaffold-3.4.14 lib/active_scaffold/config/search.rb
active_scaffold-3.4.13 lib/active_scaffold/config/search.rb
active_scaffold-3.4.12 lib/active_scaffold/config/search.rb
active_scaffold-3.4.11 lib/active_scaffold/config/search.rb
active_scaffold-3.4.10 lib/active_scaffold/config/search.rb
active_scaffold-3.4.9 lib/active_scaffold/config/search.rb
active_scaffold-3.4.8 lib/active_scaffold/config/search.rb
active_scaffold-3.4.7 lib/active_scaffold/config/search.rb
active_scaffold-3.4.5 lib/active_scaffold/config/search.rb
active_scaffold-3.4.4 lib/active_scaffold/config/search.rb
active_scaffold-3.4.3 lib/active_scaffold/config/search.rb