Class: Hanami::Routes::RoutesProc Private
- Inherits:
-
Proc
- Object
- Proc
- Hanami::Routes::RoutesProc
- Defined in:
- lib/hanami/routes.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Wrapper class for the (otherwise opaque) proc returned from routes, adding an ‘#empty?` method that returns true if no routes were defined.
This is useful when needing to determine behaviour based on the presence of user-defined routes, such as determining whether to show the Hanami welcome page in Slice#load_router.
Class Method Summary collapse
- .empty ⇒ Object private
Instance Method Summary collapse
- #empty? ⇒ Boolean private
-
#initialize(proc, empty: false) ⇒ RoutesProc
constructor
private
A new instance of RoutesProc.
Constructor Details
#initialize(proc, empty: false) ⇒ RoutesProc
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of RoutesProc.
80 81 82 83 |
# File 'lib/hanami/routes.rb', line 80 def initialize(proc, empty: false) @empty = empty super(proc) end |
Class Method Details
.empty ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 |
# File 'lib/hanami/routes.rb', line 74 def self.empty new(proc {}, empty: true) end |
Instance Method Details
#empty? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
87 88 89 |
# File 'lib/hanami/routes.rb', line 87 def empty? !!@empty end |