Module: RedisHash::Predicates
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/redis_hash/concerns/predicates.rb
Instance Method Summary collapse
- #any?(&block) ⇒ Boolean
- #empty? ⇒ Boolean
- #include?(field) ⇒ Boolean (also: #has_key?, #key?, #member?)
- #value?(value) ⇒ Boolean (also: #has_value?)
Instance Method Details
#any?(&block) ⇒ Boolean
12 13 14 15 16 |
# File 'lib/redis_hash/concerns/predicates.rb', line 12 def any?(&block) return length > 0 unless block_given? to_h.any?(&block) end |
#empty? ⇒ Boolean
18 19 20 |
# File 'lib/redis_hash/concerns/predicates.rb', line 18 def empty? length == 0 end |
#include?(field) ⇒ Boolean Also known as: has_key?, key?, member?
22 23 24 |
# File 'lib/redis_hash/concerns/predicates.rb', line 22 def include?(field) hexists(redis_key, field) end |
#value?(value) ⇒ Boolean Also known as: has_value?
29 30 31 |
# File 'lib/redis_hash/concerns/predicates.rb', line 29 def value?(value) values.include? value end |