Class: RoadForest::Authorization::GrantBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/roadforest/authorization.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(salt, cache) ⇒ GrantBuilder

Returns a new instance of GrantBuilder.



9
10
11
12
13
# File 'lib/roadforest/authorization.rb', line 9

def initialize(salt, cache)
  @salt = salt
  @cache = cache
  @list = []
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



14
15
16
# File 'lib/roadforest/authorization.rb', line 14

def list
  @list
end

Instance Method Details

#add(name, params = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/roadforest/authorization.rb', line 16

def add(name, params=nil)
  canonical =
    if params.nil?
      [@salt, name]
    else
      [@salt, name, params.keys.sort.map do |key|
        [key, params[key]]
      end]
    end
  @list << @cache[canonical]
end