lib/api_taster/route.rb in api_taster-0.4.4 vs lib/api_taster/route.rb in api_taster-0.4.5
- old
+ new
@@ -1,17 +1,17 @@
module ApiTaster
class Route
cattr_accessor :route_set
cattr_accessor :routes
cattr_accessor :mappings
- cattr_accessor :inputs
+ cattr_accessor :supplied_params
cattr_accessor :obsolete_definitions
class << self
def map_routes
self.route_set = Rails.application.routes
- self.inputs = {}
+ self.supplied_params = {}
self.obsolete_definitions = []
normalise_routes!
Mapper.instance_eval(&self.mappings.call)
@@ -54,26 +54,26 @@
r[:path].to_s == path &&
r[:verb].to_s.downcase == verb.to_s.downcase
end[0]
end
- def inputs_for(route)
- unless inputs.has_key?(route[:id])
+ def params_for(route)
+ unless supplied_params.has_key?(route[:id])
return { :undefined => route }
end
- inputs[route[:id]].collect { |input| split_input(input, route) }
+ supplied_params[route[:id]].collect { |input| split_input(input, route) }
end
def missing_definitions
routes.select { |route| undefined_route?(route) }
end
private
def undefined_route?(route)
- r = inputs_for(route)
+ r = params_for(route)
r.is_a?(Hash) && r.has_key?(:undefined)
end
def discover_rack_app(app)
class_name = app.class.name.to_s
@@ -95,10 +95,10 @@
end
def split_input(input, route)
url_param_keys = route[:path].scan /:\w+/
- url_params = input.select { |k| ":#{k}".in?(url_param_keys) }
+ url_params = input.reject { |k, v| ! ":#{k}".in?(url_param_keys) }
post_params = input.diff(url_params)
{
:url_params => url_params,
:post_params => post_params