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
- #any(path, opts = {}) ⇒ 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 20 21 22 23 24 25 26 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 7 def initialize(name, resource_definition, &block) @name = name @resource_definition = resource_definition @routes = [] @version_prefix = "" if resource_definition. version_using = Array(resource_definition.[:using]) if version_using.include?(:path) @version_prefix = "#{Praxis::Request::path_version_prefix}#{resource_definition.version}" end end 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
46 47 48 49 50 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 46 def add_route(verb, path, ={}) path = Mustermann.new(prefix + path) @routes << Route.new(verb, path, resource_definition.version, **) end |
#any(path, opts = {}) ⇒ Object
42 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 42 def any(path, opts={}) add_route 'ANY', path, opts end |
#connect(path, opts = {}) ⇒ Object
40 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 40 def connect(path, opts={}) add_route 'CONNECT', path, opts end |
#delete(path, opts = {}) ⇒ Object
38 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 38 def delete(path, opts={}) add_route 'DELETE', path, opts end |
#get(path, opts = {}) ⇒ Object
34 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 34 def get(path, opts={}) add_route 'GET', path, opts end |
#head(path, opts = {}) ⇒ Object
35 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 35 def head(path, opts={}) add_route 'HEAD', path, opts end |
#options(path, opts = {}) ⇒ Object
33 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 33 def (path, opts={}) add_route 'OPTIONS', path, opts end |
#patch(path, opts = {}) ⇒ Object
41 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 41 def patch(path, opts={}) add_route 'PATCH', path, opts end |
#post(path, opts = {}) ⇒ Object
36 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 36 def post(path, opts={}) add_route 'POST', path, opts end |
#prefix(prefix = nil) ⇒ Object
28 29 30 31 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 28 def prefix(prefix=nil) @path_prefix = prefix if prefix @version_prefix + @path_prefix end |
#put(path, opts = {}) ⇒ Object
37 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 37 def put(path, opts={}) add_route 'PUT', path, opts end |
#trace(path, opts = {}) ⇒ Object
39 |
# File 'lib/praxis/skeletor/restful_routing_config.rb', line 39 def trace(path, opts={}) add_route 'TRACE', path, opts end |