Acts As Cleo now has support for Redis backed asynchronous operations.
Optional parameters are:
queue: "my_queue_to_process"
queue defaults to “cleo”
To enable Redis, change your cleo.yml to include
async: true
async defaults to false
To disable auto flushing of indexer queue
auto_flush: false
By default, auto indexer flushing is enabled
To enable auto processing of the Redis queue append
auto_enable_queue: true
to any environment you wish to have the queue auto added to your ENV
Cleo.find(int) # Find Cleo entry by Cleo native id Cleo.update(Cleo::Result) # Pass any acts_as_cleo object to this method to have it update the Cleo entry Cleo.delete(int) # Delete by Cleo id, also accepts any acts_as_cleo object or Cleo::Result Cleo.create(obj) # Creates new entry on Cleo index. Accepts any acts_as_cleo object or Cleo::Result Cleo.query(string) # Takes string search param and returns array of Cleo::Result objects
To enable on an ActiveRecord::Base model:
class MyObject < ActiveRecord::Base acts_as_cleo end
Or add optional parameters
acts_as_cleo :terms => %w{terms to be stored} acts_as_cleo :except => %w{columns to be ignored} acts_as_cleo :score=> "method or column to be used" acts_as_cleo :terms => %w{name value other}, :score => "my_score_method"
Default functionality takes all column_names and uses them as terms for Cleo search.
To specify terms to be stored in Cleo, pass :terms => [] with the column and/or method names to be stored
acts_as_cleo ignores updated_at, created_at, id by default.
You can specify more columns to ignore by passing :except => [] with column names.
By default, acts_as_cleo uses the column “name” from your model as the Cleo search name. To specify the name in Cleo, pass :name => “my_attribute_name”
To specify a Cleo score, pass :score => “name of column or function”
ActiveRecord::Base objects with acts_as_cleo get three callback functions:
set_cleo_id, create_cleo, update_cleo, and remove_from_cleo
All three of these callbacks respect the async option on cleo.yml configuration.
This gem is still in beta.
Add acts_as_cleo to your Gemfile
gem 'acts_as_cleo'
After running bundle install execute the generate script to install acts_as_cleo
rails g acts_as_cleo:install
This generate command will install the following files:
-
app/jobs/cleo_processor.rb
-
config/cleo.yml
-
config/initalizers/cleo_initalizer.rb
-
db/migrate/#{timestamp or sequence number}_install_acts_as_cleo.rb
Verify server settings in config/cleo.yml
Run migrations
rake db:migrate
Feel free to use this gem and provide feedback / patch requests.
Acts As Cleo is a Rails gem that allows for easy integration with Linked In’s Open Source type ahead manager.
Verify that you have downloaded and installed cleo locally.
-
Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet.
-
Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it.
-
Fork the project.
-
Start a feature/bugfix branch.
-
Commit and push until you are happy with your contribution.
-
Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
-
verify that cleo is running locally.
-
rake
Copyright © 2012 Robert R. Meyer. See LICENSE.txt for further details.