lib/apidiesel/action.rb in apidiesel-0.1.1 vs lib/apidiesel/action.rb in apidiesel-0.1.2

- old
+ new

@@ -5,10 +5,11 @@ extend Dsl # accessors for class instance variables # (class-level variables, not shared with subclasses) class << self + attr_reader :url_args # Hash for storing validation closures. These closures are called with the request # parameters before the request is made and have the opportunity to check and modify them. def parameter_validations @parameter_validations ||= [] @@ -47,15 +48,17 @@ # Combined getter/setter for this actions URL # # Falls back to the Api setting if blank. # # @param [String] value - def url(value = nil) + def url(value = nil, **args) + return @url unless value || args.any? + if value - @url = value + @url = URI.parse(value) else - @url + @url_args = args end end # Combined getter/setter for the HTTP method used # @@ -120,10 +123,18 @@ def endpoint self.class.endpoint end def url - self.class.url || @api.class.url + url = self.class.url || @api.class.url + + if self.class.url_args + self.class.url_args.each do |key, value| + url.send("#{key}=", value) + end + end + + url end def http_method self.class.http_method || @api.class.http_method end