Class: Data::Criteria
- Inherits:
-
Object
- Object
- Data::Criteria
- Defined in:
- lib/data/criteria.rb,
lib/data/criteria/matcher.rb,
lib/data/criteria/version.rb,
lib/data/criteria/hash_proxy.rb,
lib/data/criteria/matcher_factory.rb
Defined Under Namespace
Classes: BaseMatcher, EqMatcher, HashProxy, InMatcher, MatcherFactory, NumericComparisonMatcher, RegexpMatcher
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
- #add(opts) ⇒ Object
-
#initialize(opts = {}) ⇒ Criteria
constructor
A new instance of Criteria.
- #match_all?(hash) ⇒ Boolean
- #match_any?(hash) ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ Criteria
Returns a new instance of Criteria.
8 9 10 11 |
# File 'lib/data/criteria.rb', line 8 def initialize(opts = {}) @matchers = {} add opts end |
Instance Method Details
#add(opts) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/data/criteria.rb', line 13 def add(opts) opts.each do |key, expected| matcher = expected.respond_to?(:call) ? expected : MatcherFactory.create(expected) add_matcher key, matcher end self end |