Class: RoadForest::Authorization::GrantBuilder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cache) ⇒ GrantBuilder

Returns a new instance of GrantBuilder.



4
5
6
7
# File 'lib/roadforest/authorization/grant-builder.rb', line 4

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

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



8
9
10
# File 'lib/roadforest/authorization/grant-builder.rb', line 8

def list
  @list
end

Instance Method Details

#add(name, params = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/roadforest/authorization/grant-builder.rb', line 10

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