Class: RoadForest::Authorization::GrantBuilder
- Inherits:
-
Object
- Object
- RoadForest::Authorization::GrantBuilder
- Defined in:
- lib/roadforest/authorization/grant-builder.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Instance Method Summary collapse
- #add(name, params = nil) ⇒ Object
-
#initialize(cache) ⇒ GrantBuilder
constructor
A new instance of GrantBuilder.
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
#list ⇒ Object (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 |