Sha256: 090caac9b9ed25b8ee164ff5fab4e273bd22a35198d544351b560b6d0b1d6c9b
Contents?: true
Size: 703 Bytes
Versions: 5
Compression:
Stored size: 703 Bytes
Contents
# frozen_string_literal: true require 'cacchern/member' module Cacchern class Set attr_reader :key class << self def contain_class(klass) @value_class = klass end def value_class @value_class || Member end end def initialize(key) @key = "#{self.class.name.underscore}:#{key}" end def all values = Redis.current.smembers @key values.map { |value| self.class.value_class.new(value) } end def add(value) return false unless value.instance_of?(self.class.value_class) if value.valid? Redis.current.sadd @key, value.value true else false end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
cacchern-0.0.7 | lib/cacchern/set.rb |
cacchern-0.0.6 | lib/cacchern/set.rb |
cacchern-0.0.5 | lib/cacchern/set.rb |
cacchern-0.0.4 | lib/cacchern/set.rb |
cacchern-0.0.3 | lib/cacchern/set.rb |