Class: Atoms::Route
- Inherits:
-
Object
- Object
- Atoms::Route
- Defined in:
- lib/atoms.rb
Class Attribute Summary collapse
-
.ns ⇒ Object
Returns the value of attribute ns.
Class Method Summary collapse
- .get(path, &block) ⇒ Object
- .header(path) ⇒ Object
- .namespace(space = nil, &block) ⇒ Object (also: group, resource, resources)
- .nest(*blocks) ⇒ Object
Class Attribute Details
.ns ⇒ Object
Returns the value of attribute ns.
54 55 56 |
# File 'lib/atoms.rb', line 54 def ns @ns end |
Class Method Details
.get(path, &block) ⇒ Object
74 75 76 77 |
# File 'lib/atoms.rb', line 74 def get(path, &block); endpoint = Atoms::Endpoint.generate(header(path), &block) Atoms::Router.add endpoint end |
.header(path) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/atoms.rb', line 79 def header(path) parts = [] parts << self.to_s #parts << version.to_s if version parts << ns.collect{ |n| n.capitalize }.join('.') if ns #parts << ns.to_s.capitalize if ns parts << path.to_s.capitalize if path p = parts.join('.') puts p p end |
.namespace(space = nil, &block) ⇒ Object Also known as: group, resource, resources
56 57 58 59 60 61 |
# File 'lib/atoms.rb', line 56 def namespace(space = nil, &block) @ns ||= [] @ns << space nest(block) @ns.delete(space) end |
.nest(*blocks) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/atoms.rb', line 67 def nest(*blocks) blocks.reject!{ |b| b.nil? } if blocks.any? blocks.each {|b| instance_eval &b} end end |