Class: ConvenientService::Support::Cache::Entities::Caches::Hash
- Defined in:
- lib/convenient_service/support/cache/entities/caches/hash.rb
Instance Method Summary collapse
- #clear ⇒ ConvenientService::Support::Cache::Entities::Caches::Hash
-
#delete(key) ⇒ Object
Can be any type.
- #empty? ⇒ Boolean
- #exist?(key) ⇒ Boolean
-
#fetch(key, &block) ⇒ Object
Can be any type.
- #initialize(hash = {}) ⇒ void constructor
-
#read(key) ⇒ Object
Can be any type.
- #store ⇒ Hash{Object => Object}
-
#write(key, value) ⇒ Object
Can be any type.
Methods inherited from Base
#==, #[], #[]=, #keygen, keygen, #scope
Methods included from ConvenientService::Support::Concern
Constructor Details
#initialize(hash = {}) ⇒ void
12 13 14 |
# File 'lib/convenient_service/support/cache/entities/caches/hash.rb', line 12 def initialize(hash = {}) @hash = hash end |
Instance Method Details
#clear ⇒ ConvenientService::Support::Cache::Entities::Caches::Hash
95 96 97 98 99 |
# File 'lib/convenient_service/support/cache/entities/caches/hash.rb', line 95 def clear hash.clear self end |
#delete(key) ⇒ Object
Returns Can be any type.
88 89 90 |
# File 'lib/convenient_service/support/cache/entities/caches/hash.rb', line 88 def delete(key) hash.delete(key) end |
#empty? ⇒ Boolean
29 30 31 |
# File 'lib/convenient_service/support/cache/entities/caches/hash.rb', line 29 def empty? hash.empty? end |
#exist?(key) ⇒ Boolean
40 41 42 |
# File 'lib/convenient_service/support/cache/entities/caches/hash.rb', line 40 def exist?(key) hash.has_key?(key) end |
#fetch(key, &block) ⇒ Object
Returns Can be any type.
75 76 77 78 79 |
# File 'lib/convenient_service/support/cache/entities/caches/hash.rb', line 75 def fetch(key, &block) return hash[key] unless block hash.fetch(key) { hash[key] = yield } end |
#read(key) ⇒ Object
Returns Can be any type.
51 52 53 |
# File 'lib/convenient_service/support/cache/entities/caches/hash.rb', line 51 def read(key) hash[key] end |
#store ⇒ Hash{Object => Object}
19 20 21 |
# File 'lib/convenient_service/support/cache/entities/caches/hash.rb', line 19 def store hash end |
#write(key, value) ⇒ Object
Returns Can be any type.
63 64 65 |
# File 'lib/convenient_service/support/cache/entities/caches/hash.rb', line 63 def write(key, value) hash[key] = value end |