Class: ActiveScaffold::Config::Search

Inherits:
Base show all
Defined in:
lib/active_scaffold/config/search.rb

Constant Summary collapse

ActiveScaffold::DataStructures::ActionLink.new('show_search', :label => :search, :type => :collection, :security_method => :search_authorized?, :ignore_method => :search_ignore?)
@@text_search =
:full
@@split_terms =
' '

Constants inherited from Base

Base::NO_FORMATS

Instance Attribute Summary collapse

Attributes inherited from Base

#action_group, #core, #formats, #user_settings_key

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#crud_type, inherited, #label, #model_id, #new_user_settings, #setup_user_setting_key, #user

Methods included from ActiveScaffold::Configurable

#configure, #method_missing, #respond_to_missing?

Constructor Details

#initialize(core_config) ⇒ Search

Returns a new instance of Search.



5
6
7
8
9
10
# File 'lib/active_scaffold/config/search.rb', line 5

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveScaffold::Configurable

Instance Attribute Details

the ActionLink for this action



60
61
62
# File 'lib/active_scaffold/config/search.rb', line 60

def link
  @link
end

#live=(value) ⇒ Object (writeonly)

whether submits the search as you type



63
64
65
# File 'lib/active_scaffold/config/search.rb', line 63

def live=(value)
  @live = value
end

#split_termsObject

Returns the value of attribute split_terms.



57
58
59
# File 'lib/active_scaffold/config/search.rb', line 57

def split_terms
  @split_terms
end

#text_searchObject

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



55
56
57
# File 'lib/active_scaffold/config/search.rb', line 55

def text_search
  @text_search
end

Class Method Details

.live?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/active_scaffold/config/search.rb', line 29

def self.live?
  @@live
end

Instance Method Details

#columnsObject

provides access to the list of columns specifically meant for the Search to use



40
41
42
43
44
45
46
# File 'lib/active_scaffold/config/search.rb', line 40

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 defined? @columns
    self.columns = @core.columns.collect { |c| c.name if @core.columns._inheritable.include?(c.name) && c.searchable? && c.association.nil? && c.text? }.compact
  end
  @columns
end

#live?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/active_scaffold/config/search.rb', line 64

def live?
  @live
end