Changeset 355
- Timestamp:
- 08/11/08 09:22:46 (3 months ago)
- Files:
-
- trunk/plugin/acts_as_ferret/lib/act_methods.rb (modified) (2 diffs)
- trunk/plugin/acts_as_ferret/lib/acts_as_ferret.rb (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plugin/acts_as_ferret/lib/act_methods.rb
r327 r355 104 104 add_fields aaf_configuration[:additional_fields] 105 105 106 # not good at class level, index might get initialized too early107 #if options[:remote]108 # aaf_index.ensure_index_exists109 #end110 106 end 111 107 … … 136 132 137 133 def add_fields(field_config) 138 # TODO139 #field_config.each do |*args|140 # define_to_field_method *args141 #end142 134 if field_config.is_a? Hash 143 135 field_config.each_pair do |field, options| trunk/plugin/acts_as_ferret/lib/acts_as_ferret.rb
r353 r355 270 270 end 271 271 272 # count hits for a query with multiple models 273 def self.total_hits(query, models, options = {}) 274 find_index(models).total_hits query, options.merge( :models => models ) 275 end 276 277 # find ids of records with multiple models 278 # TODO pagination logic? 279 def self.find_ids(query, models, options = {}, &block) 280 find_index(models).find_ids query, options.merge( :models => models ), &block 281 end 282 272 # count hits for a query 273 def self.total_hits(query, models_or_index_name, options = {}) 274 options = add_models_to_options_if_necessary options, models_or_index_name 275 find_index(models).total_hits query, options 276 end 277 278 # find ids of records 279 def self.find_ids(query, models_or_index_name, options = {}, &block) 280 options = add_models_to_options_if_necessary options, models_or_index_name 281 find_index(models).find_ids query, options, &block 282 end 283 284 # returns an index instance suitable for searching/updating the named index. Will 285 # return a read only MultiIndex when multiple model classes are given that do not 286 # share the same physical index. 283 287 def self.find_index(models_or_index_name) 284 288 case models_or_index_name … … 287 291 when String 288 292 get_index models_or_index_name.to_sym 289 #when Array290 # get_index_for models_or_index_name291 293 else 292 294 get_index_for models_or_index_name … … 306 308 end 307 309 index = find_index(models_or_index_name) 308 multi = (MultiIndex === index or index.shared?)310 multi = (MultiIndexBase === index or index.shared?) 309 311 unless options[:per_page] 310 312 options[:limit] ||= ar_options.delete :limit … … 557 559 protected 558 560 561 def self.add_models_to_options_if_necessary(options, models_or_index_name) 562 return options if String === models_or_index_name or Symbol === models_or_index_name 563 options.merge(:models => models) 564 end 565 559 566 def self.field_config_for(fieldname, options = {}) 560 567 config = DEFAULT_FIELD_OPTIONS.merge options
