Class: Authorize::Redis::Array

Inherits:
Base
  • Object
show all
Defined in:
lib/authorize/redis/array.rb

Constant Summary

Constants inherited from Base

Base::NAMESPACE_SEPARATOR

Instance Attribute Summary

Attributes inherited from Base

#id

Instance Method Summary collapse

Methods inherited from Base

#==, #_dump, _load, connection, connection_base?, connection_manager, #db, #destroy, #eql?, exists?, #exists?, generate_key, #hash, index, load, load_all, #logger, #method_missing, new, next_counter, #reload, #respond_to?, subordinate_key, #subordinate_key, #to_yaml

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Authorize::Redis::Base

Instance Method Details

#[](index) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/authorize/redis/array.rb', line 10

def [](index)
  if index.respond_to?(:first)
    db.lrange(id, index.first, index.last)
  else
    db.lindex(id, index)
  end
end

#[]=(index, v) ⇒ Object



18
19
20
# File 'lib/authorize/redis/array.rb', line 18

def []=(index, v)
  db.lset(id, index, v)
end

#__getobj__Object



31
32
33
# File 'lib/authorize/redis/array.rb', line 31

def __getobj__
  db.lrange(id, 0, -1)
end

#popObject



27
28
29
# File 'lib/authorize/redis/array.rb', line 27

def pop
  db.rpop(id)
end

#push(v) ⇒ Object Also known as: <<



22
23
24
# File 'lib/authorize/redis/array.rb', line 22

def push(v)
  db.rpush(id, v)
end

#valid?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/authorize/redis/array.rb', line 6

def valid?
  %w(none list).include?(db.type(id))
end