Module: Chewy::Index::Wrapper
  
  
  
  
  
  
  
      - Extended by:
- ActiveSupport::Concern
    - Included in:
- Chewy::Index
    - Defined in:
- lib/chewy/index/wrapper.rb
 
Defined Under Namespace
  
    
      Modules: ClassMethods
    
  
    
  
  
    
      Instance Method Summary
      collapse
    
    
  
  
  Dynamic Method Handling
  
    This class handles dynamic methods through the method_missing method
    
  
  
    
  
  
    #method_missing(method, *args, &block)  ⇒ Object 
  
  
  
  
    | 
48
49
50
51
52
53
54
55
56
57
58
59
60
61 | # File 'lib/chewy/index/wrapper.rb', line 48
def method_missing(method, *args, &block)
  m = method.to_s
  if (name = highlight_name(m))
    highlight(name)
  elsif (name = highlight_names(m))
    highlights(name)
  elsif @attributes.key?(m)
    @attributes[m]
  elsif attribute_defined?(m)
    nil
  else
    super
  end
end | 
 
  
 
  
    Instance Method Details
    
      
  
  
    #==(other)  ⇒ Object 
  
  
  
  
    | 
28
29
30
31
32
33
34
35
36
37
38
39
40 | # File 'lib/chewy/index/wrapper.rb', line 28
def ==(other)
  return true if super
  if other.is_a?(Chewy::Index)
    self.class == other.class && (respond_to?(:id) ? id == other.id : attributes == other.attributes)
  elsif other.respond_to?(:id)
    self.class.adapter.target.is_a?(Class) &&
      other.is_a?(self.class.adapter.target) &&
      id.to_s == other.id.to_s
  else
    false
  end
end | 
 
    
      
  
  
    #initialize(attributes = {})  ⇒ Object 
  
  
  
  
    | 
24
25
26 | # File 'lib/chewy/index/wrapper.rb', line 24
def initialize(attributes = {})
  @attributes = attributes.stringify_keys
end | 
 
    
      
  
  
    #respond_to_missing?(method, include_private = false)  ⇒ Boolean 
  
  
  
  
    | 
63
64
65
66 | # File 'lib/chewy/index/wrapper.rb', line 63
def respond_to_missing?(method, include_private = false)
  m = method.to_s
  highlight_name(m) || highlight_names(m) || @attributes.key?(m) || attribute_defined?(m) || super
end |