Sha256: 43bbef39d106ae67dd2f5d951b4cc7e5df45a205e95e84e9350408db27b99d1c

Contents?: true

Size: 565 Bytes

Versions: 2

Compression:

Stored size: 565 Bytes

Contents

module SearchyJson
  class Service
    attr_reader :data_path, :primary_key, :search_fields

    def initialize(data_path:, primary_key:, search_fields: [])
      @data_path = data_path
      @primary_key = primary_key
      @search_fields = search_fields
    end

    def find(query)
      search_query = SearchyJson::Query.new(query)
      Extracter.new(search_data, search_query).call
    end

    private

    def search_data
      @search_data ||= SearchyJson::Data.new(data_path, primary_key: primary_key, search_fields: search_fields).call
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
searchy-json-0.3.1 lib/searchy/service.rb
searchy-json-0.3.0 lib/searchy/service.rb