Class: ActsAsIndexed::Configuration
- Inherits:
-
Object
- Object
- ActsAsIndexed::Configuration
- Defined in:
- lib/acts_as_indexed/configuration.rb
Overview
Used to set up and modify settings for acts_as_indexed.
Instance Attribute Summary collapse
-
#case_sensitive ⇒ Object
Enable or disable case sensitivity.
-
#disable_auto_indexing ⇒ Object
Disable indexing, useful for large test suites.
- #if_proc ⇒ Object
-
#index_file_depth ⇒ Object
Tuning value for the index partitioning.
-
#is_windows_filesystem ⇒ Object
writeonly
Disable advanced features not compatible with the Windows filesystem.
-
#min_word_size ⇒ Object
Sets the minimum length for a word in a query.
Instance Method Summary collapse
-
#index_file ⇒ Object
Since we cannot expect Rails to be available on load, it is best to put off setting the index_file attribute until as late as possible.
- #index_file=(file_path) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #is_windows_filesystem? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
38 39 40 41 42 43 44 45 46 |
# File 'lib/acts_as_indexed/configuration.rb', line 38 def initialize @index_file = nil @index_file_depth = 3 @min_word_size = 3 @if_proc = if_proc @case_sensitive = false @disable_auto_indexing = false @is_windows_filesystem = RUBY_PLATFORM[/mswin32|mingw|cygwin/] end |
Instance Attribute Details
#case_sensitive ⇒ Object
Enable or disable case sensitivity. Set to true to enable. Default is false.
26 27 28 |
# File 'lib/acts_as_indexed/configuration.rb', line 26 def case_sensitive @case_sensitive end |
#disable_auto_indexing ⇒ Object
Disable indexing, useful for large test suites. Set to false to disable. Default is false.
31 32 33 |
# File 'lib/acts_as_indexed/configuration.rb', line 31 def disable_auto_indexing @disable_auto_indexing end |
#if_proc ⇒ Object
74 75 76 |
# File 'lib/acts_as_indexed/configuration.rb', line 74 def if_proc @if_proc ||= Proc.new{true} end |
#index_file_depth ⇒ Object
Tuning value for the index partitioning. Larger values result in quicker searches, but slower indexing. Default is 3.
11 12 13 |
# File 'lib/acts_as_indexed/configuration.rb', line 11 def index_file_depth @index_file_depth end |
#is_windows_filesystem=(value) ⇒ Object (writeonly)
Disable advanced features not compatible with the Windows filesystem. Set to true to disable. Default is guessed depending on current platform.
36 37 38 |
# File 'lib/acts_as_indexed/configuration.rb', line 36 def is_windows_filesystem=(value) @is_windows_filesystem = value end |
#min_word_size ⇒ Object
Sets the minimum length for a word in a query. Words shorter than this value are ignored in searches unless preceded by the ‘+’ operator. Default is 3.
16 17 18 |
# File 'lib/acts_as_indexed/configuration.rb', line 16 def min_word_size @min_word_size end |
Instance Method Details
#index_file ⇒ Object
Since we cannot expect Rails to be available on load, it is best to put off setting the index_file attribute until as late as possible.
50 51 52 |
# File 'lib/acts_as_indexed/configuration.rb', line 50 def index_file @index_file ||= Rails.root.join('tmp', 'index') end |
#index_file=(file_path) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/acts_as_indexed/configuration.rb', line 54 def index_file=(file_path) # Under the old syntax this was an array of path parts. # If this is still using the array then rewrite to a Pathname. if file_path.is_a?(Pathname) @index_file = file_path else @index_file = Pathname.new(file_path.collect{|part| part.to_s}.join(File::SEPARATOR)) end end |
#is_windows_filesystem? ⇒ Boolean
78 79 80 |
# File 'lib/acts_as_indexed/configuration.rb', line 78 def is_windows_filesystem? !!@is_windows_filesystem end |