Class: Amber::RoutePath

Inherits:
Object
  • Object
show all
Defined in:
lib/amber/route_path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method = "GET", callback = nil) ⇒ RoutePath

Returns a new instance of RoutePath.



4
5
6
7
8
# File 'lib/amber/route_path.rb', line 4

def initialize(method = "GET", callback = nil)
  @child = {}
  @method = method
  @callback = callback
end

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



2
3
4
# File 'lib/amber/route_path.rb', line 2

def callback
  @callback
end

#childObject (readonly)

Returns the value of attribute child.



2
3
4
# File 'lib/amber/route_path.rb', line 2

def child
  @child
end

#methodObject

Returns the value of attribute method.



2
3
4
# File 'lib/amber/route_path.rb', line 2

def method
  @method
end

Instance Method Details

#add_child(path, child) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
# File 'lib/amber/route_path.rb', line 18

def add_child(path, child)
  if child.is_a? Amber::RoutePath
    @child[path] = child
    return
  end

  raise ArgumentError, "Child should be a route item"
end

#can_call?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/amber/route_path.rb', line 14

def can_call?
  @callback != nil
end

#has_child?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/amber/route_path.rb', line 10

def has_child?
  !@child.empty?
end