Sha256: ac5fca75ed146bbcb86dbce365d3136db39634315f8092b423f1013904f258a2

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

require_relative 'operator'

module ConceptQL
  module Operators
    # Represents a operator that will grab all person rows that match the given races
    #
    # Race parameters are passed in as a set of strings.  Each string represents
    # a single race.  The race string must match one of the values in the
    # concept_name column of the concept table.  If you misspell the race name
    # you won't get any matches
    class Race < Operator
      desc 'Finds all people that match the races'
      argument :races, type: :codelist, vocab: 'Race'
      types :person

      def query(db)
        db.from(:person___p)
          .join(:vocabulary__concept___vc, { vc__concept_id: :p__race_concept_id })
          .where(Sequel.function(:lower, :vc__concept_name) => arguments.map(&:downcase))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conceptql-0.2.0 lib/conceptql/operators/race.rb