Module: NoSE::Backend::FileBackend::RowMatcher
- Included in:
- DeleteStatementStep, IndexLookupStatementStep
- Defined in:
- lib/nose/backend/file.rb
Overview
Provide some helper functions which allow the matching of rows based on a set of list of conditions
Instance Method Summary collapse
-
#row_matches?(row, conditions) ⇒ Boolean
Check if a row matches the given condition.
-
#row_matches_eq?(row, conditions) ⇒ Boolean
Check if a row matches the given condition on equality predicates.
-
#row_matches_range?(row, conditions) ⇒ Boolean
Check if a row matches the given condition on the range predicate.
Instance Method Details
#row_matches?(row, conditions) ⇒ Boolean
Check if a row matches the given condition
87 88 89 90 |
# File 'lib/nose/backend/file.rb', line 87 def row_matches?(row, conditions) row_matches_eq?(row, conditions) && row_matches_range?(row, conditions) end |
#row_matches_eq?(row, conditions) ⇒ Boolean
Check if a row matches the given condition on equality predicates
94 95 96 97 98 |
# File 'lib/nose/backend/file.rb', line 94 def row_matches_eq?(row, conditions) @eq_fields.all? do |field| row[field.id] == conditions.find { |c| c.field == field }.value end end |
#row_matches_range?(row, conditions) ⇒ Boolean
Check if a row matches the given condition on the range predicate
102 103 104 105 106 107 |
# File 'lib/nose/backend/file.rb', line 102 def row_matches_range?(row, conditions) return true if @range_field.nil? range_cond = conditions.find { |c| c.field == @range_field } row[@range_field.id].send range_cond.operator, range_cond.value end |