class CQL::TagFilter

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

Attributes

tags[R]

Tags to match

Public Class Methods

new(tags) click to toggle source

Creates a new filter

# File lib/cql/filters.rb, line 10
def initialize tags
  @tags = tags
end

Public Instance Methods

execute(objects, negate) click to toggle source

Filters the input models so that only the desired ones are returned

# File lib/cql/filters.rb, line 24
def execute(objects, negate)
  method = negate ? :reject : :select

  objects.send(method) { |object| has_tags?(object, tags) }
end
has_tags?(object, target_tags) click to toggle source

Returns whether or not the object has the target tags

# File lib/cql/filters.rb, line 15
def has_tags?(object, target_tags)
  target_tags.all? { |target_tag|
    tags = object.tags
    tags = tags.collect { |tag| tag.name } unless Gem.loaded_specs['cuke_modeler'].version.version[/^0/]
    tags.include?(target_tag)
  }
end