Class: Jets::Router::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/jets/router/scope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {}, parent = nil, level = 1)
  @options = options
  @parent = parent
  @level = level
end

Instance Attribute Details

#levelObject (readonly)

Returns the value of attribute level.



4
5
6
# File 'lib/jets/router/scope.rb', line 4

def level
  @level
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/jets/router/scope.rb', line 4

def options
  @options
end

#parentObject (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_namespaceObject



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.options[: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(options={})
  self.class.new(options, self, level + 1)
end

#root?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/jets/router/scope.rb', line 11

def root?
  @parent.nil?
end