Module: BigBand::AdvancedRoutes::Route
- Defined in:
- lib/big_band/advanced_routes.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#docstring ⇒ Object
Returns the value of attribute docstring.
-
#file ⇒ Object
Returns the value of attribute file.
-
#line ⇒ Object
Returns the value of attribute line.
-
#path ⇒ Object
Returns the value of attribute path.
-
#verb ⇒ Object
Returns the value of attribute verb.
Class Method Summary collapse
Instance Method Summary collapse
- #activate(at_top = false) ⇒ Object
- #active? ⇒ Boolean
- #also_change(*other_routes) ⇒ Object
- #block ⇒ Object (also: #to_proc)
- #block=(value) ⇒ Object
- #conditions ⇒ Object
- #conditions=(value) ⇒ Object
- #deactivate ⇒ Object
- #file? ⇒ Boolean
- #inspect ⇒ Object
- #keys ⇒ Object
- #keys=(value) ⇒ Object
- #pattern ⇒ Object
- #pattern=(value) ⇒ Object
- #promote(upwards = true) ⇒ Object
- #signature ⇒ Object
- #to_route(verb, args = {}) ⇒ Object
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
64 65 66 |
# File 'lib/big_band/advanced_routes.rb', line 64 def app @app end |
#docstring ⇒ Object
Returns the value of attribute docstring.
64 65 66 |
# File 'lib/big_band/advanced_routes.rb', line 64 def docstring @docstring end |
#file ⇒ Object
Returns the value of attribute file.
64 65 66 |
# File 'lib/big_band/advanced_routes.rb', line 64 def file @file end |
#line ⇒ Object
Returns the value of attribute line.
64 65 66 |
# File 'lib/big_band/advanced_routes.rb', line 64 def line @line end |
#path ⇒ Object
Returns the value of attribute path.
64 65 66 |
# File 'lib/big_band/advanced_routes.rb', line 64 def path @path end |
#verb ⇒ Object
Returns the value of attribute verb.
64 65 66 |
# File 'lib/big_band/advanced_routes.rb', line 64 def verb @verb end |
Class Method Details
.new(verb, args = {}) ⇒ Object
60 61 62 |
# File 'lib/big_band/advanced_routes.rb', line 60 def self.new(verb, args = {}) [].to_route! verb, args end |
Instance Method Details
#activate(at_top = false) ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'lib/big_band/advanced_routes.rb', line 85 def activate(at_top = false) also_change.each { |r| r.activate } return if active? meth = at_top ? :unshift : :push (app.routes[verb] ||= []).send(meth, self) invoke_hook :route_added, verb, path, block invoke_hook :advanced_root_activated, self self end |
#active? ⇒ Boolean
81 82 83 |
# File 'lib/big_band/advanced_routes.rb', line 81 def active? app.routes[verb].include? self end |
#also_change(*other_routes) ⇒ Object
124 125 126 |
# File 'lib/big_band/advanced_routes.rb', line 124 def also_change(*other_routes) (@also_change ||= []).push(*other_routes) end |
#block ⇒ Object Also known as: to_proc
69 |
# File 'lib/big_band/advanced_routes.rb', line 69 def block; self[3]; end |
#block=(value) ⇒ Object
75 |
# File 'lib/big_band/advanced_routes.rb', line 75 def block=(value); self[3] = value; end |
#conditions ⇒ Object
68 |
# File 'lib/big_band/advanced_routes.rb', line 68 def conditions; self[2]; end |
#conditions=(value) ⇒ Object
74 |
# File 'lib/big_band/advanced_routes.rb', line 74 def conditions=(value); self[2] = value; end |
#deactivate ⇒ Object
95 96 97 98 99 100 101 102 |
# File 'lib/big_band/advanced_routes.rb', line 95 def deactivate also_change.each { |r| r.deactivate } return unless active? (app.routes[verb] ||= []).delete(signature) invoke_hook :route_removed, verb, path, block invoke_hook :advanced_root_deactivated, self self end |
#file? ⇒ Boolean
110 111 112 |
# File 'lib/big_band/advanced_routes.rb', line 110 def file? !!@file end |
#inspect ⇒ Object
114 115 116 |
# File 'lib/big_band/advanced_routes.rb', line 114 def inspect "#<BigBand::AdvancedRoutes::Route #{ivar_inspect.join ", "}>" end |
#keys ⇒ Object
67 |
# File 'lib/big_band/advanced_routes.rb', line 67 def keys; self[1]; end |
#keys=(value) ⇒ Object
73 |
# File 'lib/big_band/advanced_routes.rb', line 73 def keys=(value); self[1] = value; end |
#pattern ⇒ Object
66 |
# File 'lib/big_band/advanced_routes.rb', line 66 def pattern; self[0]; end |
#pattern=(value) ⇒ Object
72 |
# File 'lib/big_band/advanced_routes.rb', line 72 def pattern=(value); self[0] = value; end |
#promote(upwards = true) ⇒ Object
104 105 106 107 108 |
# File 'lib/big_band/advanced_routes.rb', line 104 def promote(upwards = true) also_change.each { |r| r.promote(upwards) } deactivate activate(upwards) end |
#signature ⇒ Object
77 78 79 |
# File 'lib/big_band/advanced_routes.rb', line 77 def signature [pattern, keys, conditions, block] end |
#to_route(verb, args = {}) ⇒ Object
118 119 120 121 122 |
# File 'lib/big_band/advanced_routes.rb', line 118 def to_route(verb, args = {}) args = args.dup [:app, :verb, :file, :line, :path].each { |key| args[key] ||= send(key) } super(verb, args) end |