Sha256: 00fbdfbb0fcee9c960464f9d0e57f7b86b5ae7dfcfd29588837654db41442d96

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require_relative '../operation'
require_relative 'resource'

module LedgerSync
  module Domains
    class Operation
      class Query < Resource
        class Contract < LedgerSync::Ledgers::Contract
          params do
            required(:query).value(:hash)
            required(:limit).value(:hash)
            required(:includes).value(:array)
            required(:order).value(:string)
          end
        end

        private

        def operate
          success(query)
        end

        def resources
          @resources ||= resource_class.where(params[:limit])
                                       .where(params[:query])
                                       .includes(params[:includes])
                                       .order(params[:order])
        end

        def query
          LedgerSync::Domains::Serializer::Query.new(
            serializer: params[:serializer] || serializer_for(resource: resource_class.new),
            query: resources
          )
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ledger_sync-domains-1.2.1 lib/ledger_sync/domains/operation/query.rb
ledger_sync-domains-1.2.0 lib/ledger_sync/domains/operation/query.rb
ledger_sync-domains-1.1.4 lib/ledger_sync/domains/operation/query.rb
ledger_sync-domains-1.1.3 lib/ledger_sync/domains/operation/query.rb
ledger_sync-domains-1.1.1 lib/ledger_sync/domains/operation/query.rb