Class: Querly::Check::Query

Inherits:
Struct
  • Object
show all
Defined in:
lib/querly/check.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#identifierObject

Returns the value of attribute identifier

Returns:

  • (Object)

    the current value of identifier



3
4
5
# File 'lib/querly/check.rb', line 3

def identifier
  @identifier
end

#oprObject

Returns the value of attribute opr

Returns:

  • (Object)

    the current value of opr



3
4
5
# File 'lib/querly/check.rb', line 3

def opr
  @opr
end

#tagsObject

Returns the value of attribute tags

Returns:

  • (Object)

    the current value of tags



3
4
5
# File 'lib/querly/check.rb', line 3

def tags
  @tags
end

Instance Method Details

#apply(current:, all:) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/querly/check.rb', line 4

def apply(current:, all:)
  case opr
  when :append
    current.union(all.select {|rule| match?(rule) })
  when :except
    current.reject {|rule| match?(rule) }.to_set
  when :only
    all.select {|rule| match?(rule) }.to_set
  end
end

#match?(rule) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/querly/check.rb', line 15

def match?(rule)
  rule.match?(identifier: identifier, tags: tags)
end