Class: DataMapper::Query::Conditions::RegexpComparison

Inherits:
AbstractComparison show all
Defined in:
lib/dm-core/query/conditions/comparison.rb

Overview

Tests whether the value in the record matches the expected_value regexp set for the Comparison.

Instance Attribute Summary

Attributes inherited from AbstractComparison

#loaded_value, #subject, #value

Instance Method Summary collapse

Methods inherited from AbstractComparison

descendants, inherited, #inspect, #property?, #relationship?, #slug, slug, #to_s

Methods included from Deprecate

#deprecate

Methods included from Equalizer

#equalize

Instance Method Details

#matches?(record) ⇒ Boolean

Asserts that the record value matches the comparison

Parameters:

  • record (Resource, Hash)

    The record containing the value to be matched

Returns:

  • (Boolean)


613
614
615
616
# File 'lib/dm-core/query/conditions/comparison.rb', line 613

def matches?(record)
  record_value = record_value(record)
  !record_value.nil? && record_value =~ expected
end

#valid?Boolean

Checks that the Comparison is valid

Returns:

  • (Boolean)

See Also:



623
624
625
# File 'lib/dm-core/query/conditions/comparison.rb', line 623

def valid?
  value.kind_of?(Regexp)
end