Class: MongoidSphinx::Index
- Inherits:
-
Object
- Object
- MongoidSphinx::Index
- Defined in:
- lib/mongoid_sphinx/index.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
-
#name ⇒ Object
Returns the value of attribute name.
-
#source ⇒ Object
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
- #core_name ⇒ Object
- #delta_name ⇒ Object
-
#initialize(model) ⇒ Index
constructor
A new instance of Index.
- #local_options ⇒ Object
- #options ⇒ Object
- #to_riddle ⇒ Object
Constructor Details
#initialize(model) ⇒ Index
Returns a new instance of Index.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mongoid_sphinx/index.rb', line 5 def initialize(model) @name = self.class.name_for model @model = model = model. @source = Riddle::Configuration::XMLSource.new( "#{core_name}_0", config.[:type]) if defined?(Rails) @source.xmlpipe_command = "RAILS_ENV=#{Rails.env} script/rails runner '#{model.to_s}.sphinx_stream'" else @source.xmlpipe_command = "script/runner '#{model.to_s}.sphinx_stream'" end end |
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
3 4 5 |
# File 'lib/mongoid_sphinx/index.rb', line 3 def model @model end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/mongoid_sphinx/index.rb', line 3 def name @name end |
#source ⇒ Object
Returns the value of attribute source.
3 4 5 |
# File 'lib/mongoid_sphinx/index.rb', line 3 def source @source end |
Class Method Details
.name_for(model) ⇒ Object
25 26 27 |
# File 'lib/mongoid_sphinx/index.rb', line 25 def self.name_for(model) model.name.underscore.tr(':/\\', '_') end |
Instance Method Details
#core_name ⇒ Object
17 18 19 |
# File 'lib/mongoid_sphinx/index.rb', line 17 def core_name "#{name}_core" end |
#delta_name ⇒ Object
21 22 23 |
# File 'lib/mongoid_sphinx/index.rb', line 21 def delta_name "#{name}_delta" end |
#local_options ⇒ Object
29 30 31 |
# File 'lib/mongoid_sphinx/index.rb', line 29 def end |
#options ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/mongoid_sphinx/index.rb', line 33 def = config..clone .keys.select { |key| MongoidSphinx::Configuration::IndexOptions.include?(key.to_s) }.each { |key| [key.to_sym] = [key] } end |
#to_riddle ⇒ Object
41 42 43 44 |
# File 'lib/mongoid_sphinx/index.rb', line 41 def to_riddle indexes = [to_riddle_for_core] indexes << to_riddle_for_distributed end |