Module: Chewy::Index::Witchcraft::ClassMethods

Defined in:
lib/chewy/index/witchcraft.rb

Instance Method Summary collapse

Instance Method Details

#cauldron(**options) ⇒ Object



38
39
40
# File 'lib/chewy/index/witchcraft.rb', line 38

def cauldron(**options)
  (@cauldron ||= {})[options] ||= Cauldron.new(self, **options)
end

#check_requirements!Object



24
25
26
27
28
29
30
31
32
# File 'lib/chewy/index/witchcraft.rb', line 24

def check_requirements!
  messages = []
  messages << "MethodSource gem is required for the Witchcraft, please add `gem 'method_source'` to your Gemfile" unless Proc.method_defined?(:source)
  messages << "Parser gem is required for the Witchcraft, please add `gem 'parser'` to your Gemfile" unless '::Parser'.safe_constantize
  messages << "Unparser gem is required for the Witchcraft, please add `gem 'unparser'` to your Gemfile" unless '::Unparser'.safe_constantize
  messages = messages.join("\n")

  raise messages if messages.present?
end

#witchcraft!Object



19
20
21
22
# File 'lib/chewy/index/witchcraft.rb', line 19

def witchcraft!
  self._witchcraft = true
  check_requirements!
end

#witchcraft?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/chewy/index/witchcraft.rb', line 34

def witchcraft?
  !!_witchcraft
end