Class: Chewy::Type
- Defined in:
- lib/chewy/type.rb,
lib/chewy/type/crutch.rb,
lib/chewy/type/import.rb,
lib/chewy/type/actions.rb,
lib/chewy/type/mapping.rb,
lib/chewy/type/observe.rb,
lib/chewy/type/wrapper.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/adapter/mongoid.rb,
lib/chewy/type/adapter/active_record.rb
Defined Under Namespace
Modules: Actions, Adapter, Crutch, Import, Mapping, Observe, Wrapper
Instance Attribute Summary
Attributes included from Wrapper
Class Method Summary collapse
-
.adapter ⇒ Object
Current type adapter.
- .const_missing(name) ⇒ Object
-
.index ⇒ Object
Chewy index current type belongs to.
- .method_missing(method, *args, &block) ⇒ Object
-
.scopes ⇒ Object
Returns list of public class methods defined in current type.
-
.type_name ⇒ Object
Returns type name string.
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.
34 35 36 |
# File 'lib/chewy/type.rb', line 34 def self.adapter raise NotImplementedError end |
.const_missing(name) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/chewy/type.rb', line 59 def self.const_missing(name) to_resolve = "#{self.to_s}::#{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 |
.index ⇒ Object
Chewy index current type belongs to. Defined inside ‘Chewy.create_type`
27 28 29 |
# File 'lib/chewy/type.rb', line 27 def self.index raise NotImplementedError end |
.method_missing(method, *args, &block) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/chewy/type.rb', line 50 def self.method_missing(method, *args, &block) if index.scopes.include?(method) define_singleton_method method do |*args, &block| all.scoping { index.public_send(method, *args, &block) } end send(method, *args, &block) end end |
.scopes ⇒ Object
Returns list of public class methods defined in current type
46 47 48 |
# File 'lib/chewy/type.rb', line 46 def self.scopes public_methods - Chewy::Type.public_methods end |
.type_name ⇒ Object
Returns type name string
40 41 42 |
# File 'lib/chewy/type.rb', line 40 def self.type_name adapter.type_name end |