Class: Referral::MatchesTokenNames
- Inherits:
-
Object
- Object
- Referral::MatchesTokenNames
- Defined in:
- lib/referral/matches_token_names.rb
Class Method Summary collapse
- .entirely(tokens, query) ⇒ Object
- .names_from_query(query) ⇒ Object
- .names_from_tokens(tokens) ⇒ Object
- .subset(tokens, query) ⇒ Object
Class Method Details
.entirely(tokens, query) ⇒ Object
10 11 12 |
# File 'lib/referral/matches_token_names.rb', line 10 def self.entirely(tokens, query) names_from_tokens(tokens) == names_from_query(query) end |
.names_from_query(query) ⇒ Object
18 19 20 |
# File 'lib/referral/matches_token_names.rb', line 18 def self.names_from_query(query) query.split(Regexp.union(JOIN_SEPARATORS.values)) end |
.names_from_tokens(tokens) ⇒ Object
14 15 16 |
# File 'lib/referral/matches_token_names.rb', line 14 def self.names_from_tokens(tokens) tokens.reject { |t| t.name.nil? }.map { |t| t.name.to_s } end |
.subset(tokens, query) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/referral/matches_token_names.rb', line 3 def self.subset(tokens, query) token_tokens = names_from_tokens(tokens) query_tokens = names_from_query(query) token_tokens & query_tokens == query_tokens end |