Sha256: 59f97d4679ccaeac05f6ada319938852513f62a8c9f960e0ddda122f95105e58
Contents?: true
Size: 1.12 KB
Versions: 7
Compression:
Stored size: 1.12 KB
Contents
require "ribose/actions/base" module Ribose module Actions module Fetch extend Ribose::Actions::Base # Fetch A Resource # # Retrieve the details for a specific resource via HTTP GET # and retrurns those as `Sawyer::Resource`. # # @return [Sawyer::Resource] # def fetch response = Request.get(resource_path, custom_option) extract_resource(response) || response end private def extract_resource(response) unless resource.nil? response[resource.to_s] end end module ClassMethods # Fetch A Resource # # This exposes the `#fetch` instance method as class methods. Once # this methods is invoked then it will create an instnace with all # of the provided attributes & then invoke the `fetch` action on it # # @param resource_id [String] The specific resource Id # @return [Sawyer::Resource] # def fetch(resource_id, options = {}) new(options.merge(resource_id: resource_id)).fetch end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems