Sha256: 88ec60f08e119c36f03181733d3f67b71320b06c9ccbe8c8b5ecd208bb7fcb18
Contents?: true
Size: 1007 Bytes
Versions: 1
Compression:
Stored size: 1007 Bytes
Contents
module Elastic::Railties module IndexableRecord def self.included(_base) _base.extend ClassMethods end module ClassMethods def index_class @index_class ||= to_s + 'Index' end def index_class=(_class) @constantized_index_class = nil @index_class = _class end def constantized_index_class @constantized_index_class ||= index_class.constantize end def index(_options) on = _options.delete(:on) if on == :create index_on_create _options elsif on == :save index_on_save _options end end def index_on_create(_options = {}) after_create(_options) { index_later } end def index_on_save(_options = {}) after_save(_options) { index_later } end end def index_now self.class.constantized_index_class.index self end def index_later # TODO: ActiveJob support index_now end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
elastic-rails-0.5.0 | lib/elastic/railties/indexable_record.rb |