Module: RedisHash::Predicates

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/redis_hash/concerns/predicates.rb

Instance Method Summary collapse

Instance Method Details

#any?(&block) ⇒ Boolean

Returns:

  • (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

Returns:

  • (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?

Returns:

  • (Boolean)


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?

Returns:

  • (Boolean)


29
30
31
# File 'lib/redis_hash/concerns/predicates.rb', line 29

def value?(value)
  values.include? value
end