Class: Amber::RoutePath
- Inherits:
-
Object
- Object
- Amber::RoutePath
- Defined in:
- lib/amber/route_path.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#child ⇒ Object
readonly
Returns the value of attribute child.
-
#method ⇒ Object
Returns the value of attribute method.
Instance Method Summary collapse
- #add_child(path, child) ⇒ Object
- #can_call? ⇒ Boolean
- #has_child? ⇒ Boolean
-
#initialize(method = "GET", callback = nil) ⇒ RoutePath
constructor
A new instance of RoutePath.
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
#callback ⇒ Object
Returns the value of attribute callback.
2 3 4 |
# File 'lib/amber/route_path.rb', line 2 def callback @callback end |
#child ⇒ Object (readonly)
Returns the value of attribute child.
2 3 4 |
# File 'lib/amber/route_path.rb', line 2 def child @child end |
#method ⇒ Object
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
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
14 15 16 |
# File 'lib/amber/route_path.rb', line 14 def can_call? @callback != nil end |
#has_child? ⇒ Boolean
10 11 12 |
# File 'lib/amber/route_path.rb', line 10 def has_child? !@child.empty? end |