Class: DataMapper::Query::Conditions::Comparison
- Inherits:
-
Object
- Object
- DataMapper::Query::Conditions::Comparison
- Defined in:
- lib/dm-core/query/conditions/comparison.rb
Overview
An abstract class which provides easy access to comparison operators
Class Method Summary collapse
-
.comparison_class(slug) ⇒ AbstractComparison?
private
Returns the comparison class identified by the given slug.
-
.new(slug, subject, value) ⇒ DataMapper::Query::Conditions::AbstractComparison
Creates a new Comparison instance.
-
.slugs ⇒ Array<Symbol>
private
Returns an array of all slugs registered with Comparison.
Class Method Details
.comparison_class(slug) ⇒ AbstractComparison?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the comparison class identified by the given slug
75 76 77 78 79 80 |
# File 'lib/dm-core/query/conditions/comparison.rb', line 75 def self.comparison_class(slug) comparison_classes[slug] ||= AbstractComparison.descendants.detect do |comparison_class| comparison_class.slug == slug end end |
.new(slug, subject, value) ⇒ DataMapper::Query::Conditions::AbstractComparison
Creates a new Comparison instance
The returned instance will be suitable for matching the given subject (property or relationship) against the value.
58 59 60 61 62 63 64 65 |
# File 'lib/dm-core/query/conditions/comparison.rb', line 58 def self.new(slug, subject, value) if klass = comparison_class(slug) klass.new(subject, value) else raise ArgumentError, "No Comparison class for `#{slug.inspect}' has been defined" end end |
.slugs ⇒ Array<Symbol>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an array of all slugs registered with Comparison
87 88 89 90 91 92 |
# File 'lib/dm-core/query/conditions/comparison.rb', line 87 def self.slugs @slugs ||= AbstractComparison.descendants.map do |comparison_class| comparison_class.slug end.freeze end |