Module: MSFL::Validators::Definitions::HashKey
- Included in:
- Converters::Operator, Datasets::Base, Semantic
- Defined in:
- lib/msfl/validators/definitions/hash_key.rb
Instance Method Summary collapse
-
#all_logical_operators?(arr) ⇒ Bool
Returns true if all elements of arr are logical operators, false otherwise.
-
#all_operators?(arr) ⇒ Bool
Returns true if all elements of arr are operators, false otherwise.
-
#any_operators?(arr) ⇒ Bool
Returns true if any of the elements in arr are operators, otherwise false.
- #binary_operators ⇒ Object
- #foreign_operators ⇒ Object
-
#hash_key_operators ⇒ Object
Operators still needing parsing: ellipsis2, tilda.
- #logical_operators ⇒ Object
-
#operator?(symbol) ⇒ Bool
Returns true if the argument is a valid operator.
- #partial_operators ⇒ Object
- #valid_hash_key?(key) ⇒ Boolean
- #valid_hash_keys ⇒ Object
Instance Method Details
#all_logical_operators?(arr) ⇒ Bool
Returns true if all elements of arr are logical operators, false otherwise
80 81 82 83 84 85 |
# File 'lib/msfl/validators/definitions/hash_key.rb', line 80 def all_logical_operators?(arr) arr.each do |e| return false unless logical_operators.include?(e) end true end |
#all_operators?(arr) ⇒ Bool
Returns true if all elements of arr are operators, false otherwise
68 69 70 71 72 73 |
# File 'lib/msfl/validators/definitions/hash_key.rb', line 68 def all_operators?(arr) arr.each do |e| return false unless hash_key_operators.include?(e) end true end |
#any_operators?(arr) ⇒ Bool
Returns true if any of the elements in arr are operators, otherwise false
91 92 93 94 95 96 |
# File 'lib/msfl/validators/definitions/hash_key.rb', line 91 def any_operators?(arr) arr.each do |e| return true if hash_key_operators.include?(e) end false end |
#binary_operators ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/msfl/validators/definitions/hash_key.rb', line 19 def binary_operators [ :in, # IN :between, # inclusive range for integers, dates, and date times :start, # a range bound inclusively to the left :end, # a range bound inclusively to the right :ellipsis2, # alias to :between :tilda, # alias to :between, :start, and :end depending on usage :eq, # == :lt, # < :lte, # <= :gt, # > :gte, # >= :neg, # logical negation ] end |
#foreign_operators ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/msfl/validators/definitions/hash_key.rb', line 44 def foreign_operators [ :foreign, # Defines a filter on a related item :dataset, # A foreign dataset :filter, # an explicit filter ] end |
#hash_key_operators ⇒ Object
Operators still needing parsing: ellipsis2, tilda
15 16 17 |
# File 'lib/msfl/validators/definitions/hash_key.rb', line 15 def hash_key_operators binary_operators.concat(logical_operators).concat(partial_operators).concat(foreign_operators) end |
#logical_operators ⇒ Object
52 53 54 |
# File 'lib/msfl/validators/definitions/hash_key.rb', line 52 def logical_operators [:and, :or] end |
#operator?(symbol) ⇒ Bool
Returns true if the argument is a valid operator
60 61 62 |
# File 'lib/msfl/validators/definitions/hash_key.rb', line 60 def operator?(symbol) hash_key_operators.include? symbol end |
#partial_operators ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/msfl/validators/definitions/hash_key.rb', line 36 def partial_operators [ :partial, # faceted / aggregate :given, # given :filter, # explicit filter ] end |
#valid_hash_key?(key) ⇒ Boolean
6 7 8 |
# File 'lib/msfl/validators/definitions/hash_key.rb', line 6 def valid_hash_key?(key) self.dataset.has_operator?(key) || self.dataset.has_field?(key) end |
#valid_hash_keys ⇒ Object
10 11 12 |
# File 'lib/msfl/validators/definitions/hash_key.rb', line 10 def valid_hash_keys hash_key_operators.concat self.dataset.fields end |