Sha256: 3edfa43ac6fa8b6f701356e0d11d93f911af652ccb41c852cbbe5a832f06d4f7
Contents?: true
Size: 726 Bytes
Versions: 2
Compression:
Stored size: 726 Bytes
Contents
# frozen_string_literal: true module Meta module JsonSchema class ScopeMatcher attr_reader :defined_scopes def initialize(query_clause) query_clause = [query_clause] if query_clause.is_a?(String) || query_clause.is_a?(Symbol) query_clause = { some_of: query_clause } if query_clause.is_a?(Array) @match_type, @defined_scopes = query_clause.first end def match?(scopes) return false if scopes.empty? case @match_type when :some_of (@defined_scopes & scopes).any? when :all_of (@defined_scopes - scopes).empty? else raise "Unknown match type: #{@match_type}" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
meta-api-0.1.1 | lib//meta/json_schema/support/scope_matcher.rb |
meta-api-0.1.0 | lib//meta/json_schema/support/scope_matcher.rb |