Class: Chewy::Type
- Defined in:
- lib/chewy/type.rb,
lib/chewy/type/crutch.rb,
lib/chewy/type/import.rb,
lib/chewy/type/syncer.rb,
lib/chewy/type/actions.rb,
lib/chewy/type/mapping.rb,
lib/chewy/type/observe.rb,
lib/chewy/type/wrapper.rb,
lib/chewy/type/witchcraft.rb,
lib/chewy/type/adapter/orm.rb,
lib/chewy/type/adapter/base.rb,
lib/chewy/type/adapter/object.rb,
lib/chewy/type/adapter/sequel.rb,
lib/chewy/type/import/routine.rb,
lib/chewy/type/adapter/mongoid.rb,
lib/chewy/type/import/bulk_builder.rb,
lib/chewy/type/import/bulk_request.rb,
lib/chewy/type/adapter/active_record.rb,
lib/chewy/type/import/journal_builder.rb
Defined Under Namespace
Modules: Actions, Adapter, Crutch, Import, Mapping, Observe, Witchcraft, Wrapper Classes: Syncer
Constant Summary collapse
- IMPORT_OPTIONS_KEYS =
%i[batch_size bulk_size refresh consistency replication raw_import journal pipeline].freeze
Constants included from Import
Import::IMPORT_WORKER, Import::LEFTOVERS_WORKER
Class Method Summary collapse
-
.adapter ⇒ Object
Current type adapter.
- .const_missing(name) ⇒ Object
- .default_import_options(params) ⇒ Object
-
.derivable_name ⇒ String?
Appends type name to Index.derivable_name.
-
.index ⇒ Object
Chewy index current type belongs to.
- .method_missing(method, *args, &block) ⇒ Object
- .respond_to_missing?(method, _) ⇒ Boolean
-
.scopes ⇒ Object
Returns list of public class methods defined in current type.
-
.type_name ⇒ Object
Returns type name string.
-
.types ⇒ Chewy::Type
This method is an API shared with Index, added for convenience.
Methods included from Observe::Helpers
#extract_callback_options!, #update_proc
Methods included from Wrapper
#==, #initialize, #method_missing, #respond_to_missing?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Chewy::Type::Wrapper
Class Method Details
.adapter ⇒ Object
Current type adapter. Defined inside Chewy.create_type
, derived from
Chewy::Index.define_type
arguments.
43 44 45 |
# File 'lib/chewy/type.rb', line 43 def adapter raise NotImplementedError end |
.const_missing(name) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/chewy/type.rb', line 100 def const_missing(name) to_resolve = "#{self}::#{name}" to_resolve[index.to_s] = '' @__resolved_constants ||= {} if to_resolve.empty? || @__resolved_constants[to_resolve] super else @__resolved_constants[to_resolve] = true to_resolve.constantize end rescue NotImplementedError super end |
.default_import_options(params) ⇒ Object
80 81 82 83 |
# File 'lib/chewy/type.rb', line 80 def (params) params.assert_valid_keys(IMPORT_OPTIONS_KEYS) self. = .merge(params) end |
.derivable_name ⇒ String?
Appends type name to Index.derivable_name
63 64 65 |
# File 'lib/chewy/type.rb', line 63 def derivable_name @derivable_name ||= [index.derivable_name, type_name].join('#') if index && index.derivable_name end |
.index ⇒ Object
Chewy index current type belongs to. Defined inside Chewy.create_type
36 37 38 |
# File 'lib/chewy/type.rb', line 36 def index raise NotImplementedError, 'Looks like this type was defined outside the index scope and `.index` method is undefined for it' end |
.method_missing(method, *args, &block) ⇒ Object
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/chewy/type.rb', line 85 def method_missing(method, *args, &block) if index.scopes.include?(method) define_singleton_method method do |*method_args, &method_block| all.scoping { index.public_send(method, *method_args, &method_block) } end send(method, *args, &block) else super end end |
.respond_to_missing?(method, _) ⇒ Boolean
96 97 98 |
# File 'lib/chewy/type.rb', line 96 def respond_to_missing?(method, _) index.scopes.include?(method) || super end |
.scopes ⇒ Object
Returns list of public class methods defined in current type
76 77 78 |
# File 'lib/chewy/type.rb', line 76 def scopes public_methods - Chewy::Type.public_methods end |
.type_name ⇒ Object
Returns type name string
49 50 51 |
# File 'lib/chewy/type.rb', line 49 def type_name adapter.type_name end |
.types ⇒ Chewy::Type
This method is an API shared with Index, added for convenience.
70 71 72 |
# File 'lib/chewy/type.rb', line 70 def types [self] end |