Class: Authorize::Redis::Hash

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

Direct Known Subclasses

Graph::Edge, Graph::Vertex

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

#__getobj__Object



29
30
31
# File 'lib/authorize/redis/hash.rb', line 29

def __getobj__
  db.hgetall(id)
end

#get(k) ⇒ Object Also known as: []



10
11
12
# File 'lib/authorize/redis/hash.rb', line 10

def get(k)
  db.hget(id, k)
end

#merge(h) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/authorize/redis/hash.rb', line 20

def merge(h)
  return self if h.empty?
  args = h.inject([]) do |m,(k,v)|
    m << k
    m << v
  end
  db.hmset(id, *args)
end

#set(k, v) ⇒ Object Also known as: []=



15
16
17
# File 'lib/authorize/redis/hash.rb', line 15

def set(k, v)
  db.hset(id, k, v)
end

#valid?Boolean

Returns:

  • (Boolean)


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

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