Class: Radical::Routes
- Inherits:
-
Object
- Object
- Radical::Routes
- Extended by:
- T::Sig
- Defined in:
- lib/radical/routes.rb
Direct Known Subclasses
Class Method Summary collapse
- .parents ⇒ Object
- .resource(*names) ⇒ Object
- .resources(*names, &block) ⇒ Object
- .root(name) ⇒ Object
- .router ⇒ Object
Class Method Details
.parents ⇒ Object
16 17 18 |
# File 'lib/radical/routes.rb', line 16 def parents @parents ||= [] end |
.resource(*names) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/radical/routes.rb', line 28 def resource(*names) classes = names.map { |c| Object.const_get(c) } classes.each do |klass| router.add_resource(klass) end end |
.resources(*names, &block) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/radical/routes.rb', line 37 def resources(*names, &block) classes = names.map { |c| Object.const_get(c) } classes.each do |klass| if parents.any? router.add_resources(klass, parents: @parents) # only one level of nesting @parents = [] else router.add_resources(klass) end end return unless block @parents = classes block.call end |
.root(name) ⇒ Object
21 22 23 24 25 |
# File 'lib/radical/routes.rb', line 21 def root(name) klass = Object.const_get(name) router.add_root(klass) end |