Class: Praxis::Skeletor::RestfulRoutingConfig
- Inherits:
-
Object
- Object
- Praxis::Skeletor::RestfulRoutingConfig
- Defined in:
- lib/praxis/skeletor/restful_routing_config.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#resource_definition ⇒ Object
readonly
Returns the value of attribute resource_definition.
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
Instance Method Summary collapse
- #add_route(verb, path, options = {}) ⇒ Object
- #connect(path, opts = {}) ⇒ Object
- #delete(path, opts = {}) ⇒ Object
- #get(path, opts = {}) ⇒ Object
- #head(path, opts = {}) ⇒ Object
-
#initialize(name, resource_definition, &block) ⇒ RestfulRoutingConfig
constructor
A new instance of RestfulRoutingConfig.
- #options(path, opts = {}) ⇒ Object
- #patch(path, opts = {}) ⇒ Object
- #post(path, opts = {}) ⇒ Object
- #prefix(prefix = nil) ⇒ Object
- #put(path, opts = {}) ⇒ Object
- #trace(path, opts = {}) ⇒ Object
Constructor Details
#initialize(name, resource_definition, &block) ⇒ RestfulRoutingConfig
Returns a new instance of RestfulRoutingConfig.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 7 def initialize(name, resource_definition, &block) @name = name @resource_definition = resource_definition @routes = [] @prefix = "/" + resource_definition.name.split("::").last.underscore if resource_definition.routing_config instance_eval(&resource_definition.routing_config) end instance_eval(&block) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 5 def name @name end |
#resource_definition ⇒ Object (readonly)
Returns the value of attribute resource_definition.
5 6 7 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 5 def resource_definition @resource_definition end |
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
5 6 7 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 5 def routes @routes end |
Instance Method Details
#add_route(verb, path, options = {}) ⇒ Object
36 37 38 39 40 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 36 def add_route(verb, path, ={}) path = Mustermann.new(@prefix + path) @routes << Route.new(verb, path, resource_definition.version, **) end |
#connect(path, opts = {}) ⇒ Object
33 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 33 def connect(path, opts={}) add_route 'CONNECT', path, opts end |
#delete(path, opts = {}) ⇒ Object
31 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 31 def delete(path, opts={}) add_route 'DELETE', path, opts end |
#get(path, opts = {}) ⇒ Object
27 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 27 def get(path, opts={}) add_route 'GET', path, opts end |
#head(path, opts = {}) ⇒ Object
28 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 28 def head(path, opts={}) add_route 'HEAD', path, opts end |
#options(path, opts = {}) ⇒ Object
26 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 26 def (path, opts={}) add_route 'OPTIONS', path, opts end |
#patch(path, opts = {}) ⇒ Object
34 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 34 def patch(path, opts={}) add_route 'PATCH', path, opts end |
#post(path, opts = {}) ⇒ Object
29 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 29 def post(path, opts={}) add_route 'POST', path, opts end |
#prefix(prefix = nil) ⇒ Object
21 22 23 24 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 21 def prefix(prefix=nil) return @prefix unless prefix @prefix = prefix end |
#put(path, opts = {}) ⇒ Object
30 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 30 def put(path, opts={}) add_route 'PUT', path, opts end |
#trace(path, opts = {}) ⇒ Object
32 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 32 def trace(path, opts={}) add_route 'TRACE', path, opts end |