Sha256: b046130f1bd6d44bf52867b8bae59063d1a161927de2327002b84302f3c72fcb

Contents?: true

Size: 777 Bytes

Versions: 10

Compression:

Stored size: 777 Bytes

Contents

module Waistband
  class Result

    def initialize(result_hash)
      @result_hash = result_hash
    end

    def to_hash
      @result_hash['_source']
    end

    def [](key)
      @result_hash['_source'][key.to_s]
    end

    def method_missing(method_name, *args, &block)
      return @result_hash[method_name.to_s] if @result_hash.has_key?(method_name.to_s)
      return @result_hash['_source'][method_name.to_s] if @result_hash['_source'] && @result_hash['_source'].has_key?(method_name.to_s)
      nil
    end

    def respond_to_missing?(method_name, include_private = false)
      return true if @result_hash.has_key?(method_name.to_s)
      return true if @result_hash['_source'] && @result_hash['_source'].has_key?(method_name.to_s)
      super
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
waistband-6.3.0 lib/waistband/result.rb
waistband-6.2.0 lib/waistband/result.rb
waistband-6.1.1 lib/waistband/result.rb
waistband-6.1.0 lib/waistband/result.rb
waistband-6.0.0 lib/waistband/result.rb
waistband-0.16.7 lib/waistband/result.rb
waistband-0.16.6 lib/waistband/result.rb
waistband-0.16.5 lib/waistband/result.rb
waistband-0.16.3 lib/waistband/result.rb
waistband-0.16.2 lib/waistband/result.rb