Project

esse-hooks

0.0
The project is in a healthy, maintained state
A set of hooks extensions for Esse, the Ruby ElasticSearch and OpenSearch client.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 0.3.0
 Project Readme

Esse Hooks Extension

This gem is an internal component for the esse project. It provides a plugin to add hooks to the esse-active_record and esse-sequel plugins.

Installation

Add this line to your application's Gemfile:

gem 'esse-hooks'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install esse-hooks

Usage

Using the esse-active_record as example. It adds hooks to the Esse::ActiveRecord::Hooks module.

module Esse::ActiveRecord::Hooks
  include Esse::Hooks[store_key: :esse_active_record_hooks]
end

and then you can use the hooks to change activeness of the indexing process.

Esse::ActiveRecord::Hooks.disable!
Esse::ActiveRecord::Hooks.with_indexing do
  10.times { User.create! }
end

Esse::ActiveRecord::Hooks.enable!
Esse::ActiveRecord::Hooks.without_indexing do
  10.times { User.create! }
end

or by some specific list of index or index's repository

Esse::ActiveRecord::Hooks.disable!(UsersIndex.repo)
Esse::ActiveRecord::Hooks.with_indexing(AccountsIndex, UsersIndex.repo) do
  10.times { User.create! }
end
Esse::ActiveRecord::Hooks.enable!(UsersIndex.repo)
Esse::ActiveRecord::Hooks.without_indexing(AccountsIndex, UsersIndex.repo) do
  10.times { User.create! }
end

In case you are using both esse-active_record and esse-sequel plugins, you can use the Esse::Hooks module directly to interact with both hooks at the same time.

Esse::Hooks.disable!
Esse::Hooks.with_indexing do
  10.times { User.create! }
end
Esse::Hooks.enable!

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake none to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/marcosgz/esse-hooks.

License

The gem is available as open source under the terms of the MIT License.