Module: Redis::Attrs::ClassMethods
- Defined in:
- lib/redis-attrs.rb
Instance Method Summary collapse
- #redis ⇒ Object
- #redis_attr(name, type, options = {}) ⇒ Object
- #redis_attrs(attrs = nil) ⇒ Object
- #redis_key_prefix ⇒ Object
Instance Method Details
#redis_attr(name, type, options = {}) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/redis-attrs.rb', line 33 def redis_attr(name, type, = {}) @redis_attrs ||= [] klass = Redis::Attrs.supported_types[type] raise ArgumentError, "Unknown Redis::Attr type #{type}" if klass.nil? attr = klass.new(self, name, type, ) @redis_attrs << attr end |
#redis_attrs(attrs = nil) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/redis-attrs.rb', line 25 def redis_attrs(attrs = nil) @redis_attrs ||= [] return @redis_attrs if attrs.nil? attrs.each do |name, type| redis_attr name, type end end |
#redis_key_prefix ⇒ Object
21 22 23 |
# File 'lib/redis-attrs.rb', line 21 def redis_key_prefix @redis_key_refix ||= ActiveSupport::Inflector.underscore(name) end |