Class: ThinkingSphinx::Search::Glaze

Inherits:
BasicObject
Defined in:
lib/thinking_sphinx/search/glaze.rb

Instance Method Summary collapse

Constructor Details

#initialize(context, object, raw = {}, pane_classes = []) ⇒ Glaze

Returns a new instance of Glaze.



4
5
6
7
8
9
10
# File 'lib/thinking_sphinx/search/glaze.rb', line 4

def initialize(context, object, raw = {}, pane_classes = [])
  @object, @raw = object, raw

  @panes = pane_classes.collect { |klass|
    klass.new context, object, @raw
  }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



31
32
33
34
35
36
37
38
# File 'lib/thinking_sphinx/search/glaze.rb', line 31

def method_missing(method, *args, &block)
  pane = @panes.detect { |pane| pane.respond_to?(method) }
  if @object.respond_to?(method) || pane.nil?
    @object.send(method, *args, &block)
  else
    pane.send(method, *args, &block)
  end
end

Instance Method Details

#==(object) ⇒ Object



12
13
14
# File 'lib/thinking_sphinx/search/glaze.rb', line 12

def ==(object)
  (@object == object) || super
end

#equal?(object) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/thinking_sphinx/search/glaze.rb', line 16

def equal?(object)
  @object.equal? object
end

#respond_to?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/thinking_sphinx/search/glaze.rb', line 20

def respond_to?(method, include_private = false)
  @object.respond_to?(method, include_private) ||
  @panes.any? { |pane| pane.respond_to?(method, include_private) }
end

#unglazedObject



25
26
27
# File 'lib/thinking_sphinx/search/glaze.rb', line 25

def unglazed
  @object
end