Class: ThinkingSphinx::Search::Glaze

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

Instance Method Summary (collapse)

Constructor Details

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

Returns a new instance of Glaze



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

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

- (Object) method_missing(method, *args, &block) (private)



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

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)



10
11
12
# File 'lib/thinking_sphinx/search/glaze.rb', line 10

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

- (Boolean) equal?(object)

Returns:

  • (Boolean)


14
15
16
# File 'lib/thinking_sphinx/search/glaze.rb', line 14

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

- (Boolean) respond_to?(method, include_private = false)

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/thinking_sphinx/search/glaze.rb', line 18

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

- (Object) unglazed



23
24
25
# File 'lib/thinking_sphinx/search/glaze.rb', line 23

def unglazed
  @object
end