Sha256: 941c0aefe2691f16a17748ed1ea862dc7706e11bb4cef6ae2ce15da15935e07b

Contents?: true

Size: 873 Bytes

Versions: 5

Compression:

Stored size: 873 Bytes

Contents

require "ribose/actions/base"

module Ribose
  module Actions
    module Update
      extend Ribose::Actions::Base

      # Update a resource
      #
      # @return [Sawyer::Resource] Update resource response
      def update
        response = update_resource
        response[resource] || response
      end

      private

      def update_resource
        Ribose::Request.put(
          resource_path, custom_option.merge(resource_key.to_sym => attributes)
        )
      end

      module ClassMethods
        # Update a resource
        #
        # @param resource_id [String] The Resource UUID
        # @param attributes [Hash] New attributes as Hash
        # @return [Sawyer::Resource] The Updated Resource
        def update(resource_id, attributes = {})
          new(attributes.merge(resource_id: resource_id)).update
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ribose-0.5.0 lib/ribose/actions/update.rb
ribose-0.4.1 lib/ribose/actions/update.rb
ribose-0.4.0 lib/ribose/actions/update.rb
ribose-0.3.2 lib/ribose/actions/update.rb
ribose-0.3.1 lib/ribose/actions/update.rb