Sha256: 09c397b9e17da849bf88b06d5f0402c4fd61dd4c5e56228ed156d82ef41c2180

Contents?: true

Size: 708 Bytes

Versions: 1

Compression:

Stored size: 708 Bytes

Contents

module InfinumId
  module Resources
    class Updater
      def initialize(params, resource)
        @params = params.to_h.deep_symbolize_keys
        @resource = resource
      end

      def self.call(params, resource)
        new(params, resource).call
      end

      def call
        update_resource
        InfinumId::AfterResourceUpsert.call(
          resource,
          @params,
          InfinumId::AfterResourceIntent::UPDATE
        )
      end

      private

      attr_reader :resource_params, :resource

      def update_resource
        resource.update(resource_params)
      end

      def resource_params
        @params.slice(*InfinumId.resource_attributes)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
infinum_id-2.2.0 app/services/infinum_id/resources/updater.rb