lib/weary/base.rb in weary-0.7.0 vs lib/weary/base.rb in weary-0.7.1

- old
+ new

@@ -32,12 +32,11 @@ resources[:#{resource.name}].build!(params, @defaults, @credentials) end } end - class << self - + class << self # Getter for class-level resources def resources @@resources end @@ -50,27 +49,27 @@ # [<tt>authenticates</tt>] Boolean value; does the resource require authentication? # [<tt>url</tt>] The url of the resource. You can use the same flags as #construct_url # [<tt>follows</tt>] Boolean; Does this follow redirects? Defaults to true # [<tt>headers</tt>] Set headers for the HTTP Request def get(name,&block) - build_resource(name, :get, block) + build_resource(name, :get, &block) end alias declare get # Declares a Resource to be requested via POST def post(name,&block) - build_resource(name, :post, block) + build_resource(name, :post, &block) end # Declares a Resource to be requested via PUT def put(name,&block) - build_resource(name, :put, block) + build_resource(name, :put, &block) end # Declares a Resource to be requested via DELETE def delete(name,&block) - build_resource(name, :delete, block) + build_resource(name, :delete, &block) end # Set custom default Headers for your Request def headers(headers) @headers = headers @@ -87,12 +86,12 @@ def format(format) @format = format end # Prepare and store the Resource - def build_resource(name,verb,block=nil) + def build_resource(name,verb,&block) resource = prepare_resource(name,verb) - block.call(resource) if block + yield resource if block_given? store_resource(resource) build_method(resource) resource end \ No newline at end of file