Module: RedisHash::Deletions
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/redis_hash/concerns/deletions.rb
Instance Method Summary collapse
Instance Method Details
#clear ⇒ Object
12 13 14 |
# File 'lib/redis_hash/concerns/deletions.rb', line 12 def clear del(redis_key) and {} end |
#delete(field) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/redis_hash/concerns/deletions.rb', line 16 def delete(field) run_callbacks(:deletion) do value = self[field] result = hdel(redis_key, field) (result == 0 && block_given?) ? yield(field) : value end end |
#shift ⇒ Object
24 25 26 27 28 29 |
# File 'lib/redis_hash/concerns/deletions.rb', line 24 def shift return to_default if empty? field = keys.first [ field, delete(field) ] end |