Class: MemDB::Fields::Matching
- Inherits:
-
Object
- Object
- MemDB::Fields::Matching
- Defined in:
- lib/mem_db/fields.rb
Instance Method Summary collapse
-
#initialize(fields, obj) ⇒ Matching
constructor
A new instance of Matching.
- #match?(query) ⇒ Boolean
Constructor Details
#initialize(fields, obj) ⇒ Matching
Returns a new instance of Matching.
6 7 8 9 10 11 12 13 14 |
# File 'lib/mem_db/fields.rb', line 6 def initialize(fields, obj) @matchings = fields .map do |field| [field, field.new_matching(field.field_value(obj))] end .reject! do |_field, matching| matching == MemDB::Field::MayMissing::ANY_MATCHING end end |
Instance Method Details
#match?(query) ⇒ Boolean
16 17 18 |
# File 'lib/mem_db/fields.rb', line 16 def match?(query) @matchings.all? { |field, matching| matching.match?(query.field_value(field)) } end |