Sha256: 4e42fdabcd9ed7b8033df7f800419d7f4ef8a10ffbb32507e424f2e4c93e9f63

Contents?: true

Size: 868 Bytes

Versions: 17

Compression:

Stored size: 868 Bytes

Contents

# frozen_string_literal: true

class ThinkingSphinx::Search::Glaze < BasicObject
  def initialize(context, object, raw = {}, pane_classes = [])
    @object, @raw = object, raw

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

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

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

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

  def unglazed
    @object
  end

  private

  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
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
thinking-sphinx-5.6.0 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-5.5.1 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-5.5.0 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-5.4.0 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-5.3.0 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-5.2.1 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-5.2.0 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-5.1.0 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-5.0.0 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-4.4.1 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-4.4.0 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-4.3.2 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-4.3.1 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-4.3.0 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-4.2.0 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-4.1.0 lib/thinking_sphinx/search/glaze.rb
thinking-sphinx-4.0.0 lib/thinking_sphinx/search/glaze.rb