Class: RoadForest::Authorization::GrantsHolder
- Inherits:
-
Object
- Object
- RoadForest::Authorization::GrantsHolder
- Defined in:
- lib/roadforest/authorization.rb
Instance Method Summary collapse
- #build_grants {|builder| ... } ⇒ Object
- #get(key) ⇒ Object (also: #[])
-
#initialize(salt, hash_function) ⇒ GrantsHolder
constructor
A new instance of GrantsHolder.
Constructor Details
#initialize(salt, hash_function) ⇒ GrantsHolder
Returns a new instance of GrantsHolder.
30 31 32 33 34 35 36 37 38 |
# File 'lib/roadforest/authorization.rb', line 30 def initialize(salt, hash_function) @salt = salt digester = OpenSSL::Digest.new(hash_function) @grants_cache = Hash.new do |h, k| #XXX potential resource exhaustion here - only accumulate auth'd results digester.reset h[k] = digester.digest(h.inspect) end end |
Instance Method Details
#build_grants {|builder| ... } ⇒ Object
45 46 47 48 49 |
# File 'lib/roadforest/authorization.rb', line 45 def build_grants builder = GrantBuilder.new(@salt, self) yield builder return builder.list end |
#get(key) ⇒ Object Also known as: []
40 41 42 |
# File 'lib/roadforest/authorization.rb', line 40 def get(key) @grants_cache[key] end |