Class: Jets::Router::Scope
- Inherits:
-
Object
- Object
- Jets::Router::Scope
- Defined in:
- lib/jets/router/scope.rb
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #full_namespace ⇒ Object
-
#initialize(options = {}, parent = nil, level = 1) ⇒ Scope
constructor
A new instance of Scope.
- #new(options = {}) ⇒ Object
- #root? ⇒ Boolean
Constructor Details
#initialize(options = {}, parent = nil, level = 1) ⇒ Scope
Returns a new instance of Scope.
5 6 7 8 9 |
# File 'lib/jets/router/scope.rb', line 5 def initialize( = {}, parent = nil, level = 1) @options = @parent = parent @level = level end |
Instance Attribute Details
#level ⇒ Object (readonly)
Returns the value of attribute level.
4 5 6 |
# File 'lib/jets/router/scope.rb', line 4 def level @level end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/jets/router/scope.rb', line 4 def @options end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'lib/jets/router/scope.rb', line 4 def parent @parent end |
Instance Method Details
#full_namespace ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/jets/router/scope.rb', line 19 def full_namespace ns = [] current = self while current ns.unshift(current.[:namespace]) current = current.parent end ns.empty? ? nil : ns.join('/') end |
#new(options = {}) ⇒ Object
15 16 17 |
# File 'lib/jets/router/scope.rb', line 15 def new(={}) self.class.new(, self, level + 1) end |
#root? ⇒ Boolean
11 12 13 |
# File 'lib/jets/router/scope.rb', line 11 def root? @parent.nil? end |