Class: MuchRails::Action::BaseRouter::RequestTypeSet
- Inherits:
-
Object
- Object
- MuchRails::Action::BaseRouter::RequestTypeSet
- Defined in:
- lib/much-rails/action/base_router.rb
Instance Method Summary collapse
- #add(name, constraints_lambda) ⇒ Object
- #empty? ⇒ Boolean
- #get(name) ⇒ Object
-
#initialize ⇒ RequestTypeSet
constructor
A new instance of RequestTypeSet.
Constructor Details
#initialize ⇒ RequestTypeSet
Returns a new instance of RequestTypeSet.
267 268 269 |
# File 'lib/much-rails/action/base_router.rb', line 267 def initialize @set = {} end |
Instance Method Details
#add(name, constraints_lambda) ⇒ Object
275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/much-rails/action/base_router.rb', line 275 def add(name, constraints_lambda) request_type = RequestType.new(name.to_sym, constraints_lambda) key = request_type.name unless @set[key].nil? raise( ArgumentError, "There is already a request type named `#{name.to_sym.inspect}`.", ) end @set[key] = request_type end |
#empty? ⇒ Boolean
271 272 273 |
# File 'lib/much-rails/action/base_router.rb', line 271 def empty? @set.empty? end |
#get(name) ⇒ Object
287 288 289 290 291 292 293 294 295 |
# File 'lib/much-rails/action/base_router.rb', line 287 def get(name) key = name.to_sym @set.fetch(key) do raise( ArgumentError, "There is no request type named `#{name.to_sym.inspect}`.", ) end end |