Module: RocketPants::Routing
- Defined in:
- lib/rocket_pants/routing.rb
Instance Method Summary collapse
-
#rocket_pants(options = {}, &blk) ⇒ Object
(also: #api)
Scopes a set of given api routes, allowing for option versions.
Instance Method Details
#rocket_pants(options = {}, &blk) ⇒ Object Also known as: api
Scopes a set of given api routes, allowing for option versions.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rocket_pants/routing.rb', line 9 def rocket_pants( = {}, &blk) versions = (Array(.delete(:versions)) + Array(.delete(:version))).flatten.map(&:to_s) versions.each do |version| raise ArgumentError, "Got invalid version: '#{version}'" unless version =~ /\A\d+\Z/ end versions_regexp = /(#{versions.uniq.join("|")})/ raise ArgumentError, 'please provide atleast one version' if versions.empty? = .deep_merge({ :constraints => {:version => versions_regexp}, :path => ':version', :defaults => {:format => 'json'} }) scope , &blk end |