Class: CQL::TypeCountFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/cql/filters.rb

Overview

Not a part of the public API. Subject to change at any time.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(types, comparison) ⇒ TypeCountFilter

Creates a new filter



65
66
67
68
# File 'lib/cql/filters.rb', line 65

def initialize types, comparison
  @types = types
  @comparison = comparison
end

Instance Attribute Details

#comparisonObject (readonly)

the types of object that will be filtered against



60
61
62
# File 'lib/cql/filters.rb', line 60

def comparison
  @comparison
end

#typesObject (readonly)

the types of object that will be filtered against



60
61
62
# File 'lib/cql/filters.rb', line 60

def types
  @types
end

Instance Method Details

#execute(input, negate) ⇒ Object

Not a part of the public API. Subject to change at any time. Filters the input models so that only the desired ones are returned



72
73
74
75
76
77
78
# File 'lib/cql/filters.rb', line 72

def execute(input, negate)
  method = negate ? :reject : :select

  input.send(method) do |object|
    type_count(object).send(comparison.operator, comparison.amount)
  end
end