Sha256: 85057cbf2544043d2795c158c27d2ade2da93c572b847e42bb3f6d6914a40a89

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

require "ribose/actions/base"

module Ribose
  module Actions
    module All
      extend Ribose::Actions::Base
      # List Resources
      #
      # Retrieve the list of resources via :get and then extract the
      # the root element from the response object.
      #
      # @return [Array <Sawyer::Resource>]
      #
      def all
        response = Ribose::Request.get(resources_path, custom_option)
        extract_root(response) || response
      end

      private

      def extract_root(response)
        unless resources.nil?
          response[resources]
        end
      end

      module ClassMethods
        # List Resources
        #
        # This exposes the instance method as class methods, and once
        # invoked then it instantiate a new instance & invokes the all
        # instance method with the provided parameters.
        #
        # @param options [Hash] Query parameters as Hash
        # @return [Array <Sawyer::Resource>]
        #
        def all(options = {})
          new(options).all
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ribose-0.5.0 lib/ribose/actions/all.rb
ribose-0.4.1 lib/ribose/actions/all.rb
ribose-0.4.0 lib/ribose/actions/all.rb
ribose-0.3.2 lib/ribose/actions/all.rb
ribose-0.3.1 lib/ribose/actions/all.rb
ribose-0.3.0 lib/ribose/actions/all.rb
ribose-0.2.0 lib/ribose/actions/all.rb