Sha256: 22860c5a38f76754e93aee090f5ae27bf1c4fb3bee9376ad2ae8ad9698ab92b3

Contents?: true

Size: 734 Bytes

Versions: 12

Compression:

Stored size: 734 Bytes

Contents

# frozen_string_literal: true

require 'active_support'

class DHS::Item < DHS::Proxy
  module EndpointLookup
    extend ActiveSupport::Concern

    def url_for_persistance!(data, options)
      return href if href.present?
      endpoint = endpoint_for_persistance!(data, options)
      endpoint.compile(
        merge_data_with_options(data, options)
      ).tap do
        endpoint.remove_interpolated_params!(data)
        endpoint.remove_interpolated_params!(options.fetch(:params, {}))
        options.merge!(endpoint.options.merge(options)) if endpoint.options
      end
    end

    private

    def endpoint_for_persistance!(data, options)
      record.find_endpoint(merge_data_with_options(data, options))
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dhs-1.6.0 lib/dhs/concerns/item/endpoint_lookup.rb
dhs-1.5.0 lib/dhs/concerns/item/endpoint_lookup.rb
dhs-1.4.2 lib/dhs/concerns/item/endpoint_lookup.rb
dhs-1.4.1 lib/dhs/concerns/item/endpoint_lookup.rb
dhs-1.4.0 lib/dhs/concerns/item/endpoint_lookup.rb
dhs-1.3.0 lib/dhs/concerns/item/endpoint_lookup.rb
dhs-1.2.0 lib/dhs/concerns/item/endpoint_lookup.rb
dhs-1.1.0 lib/dhs/concerns/item/endpoint_lookup.rb
dhs-1.0.3 lib/dhs/concerns/item/endpoint_lookup.rb
dhs-1.0.2 lib/dhs/concerns/item/endpoint_lookup.rb
dhs-1.0.1 lib/dhs/concerns/item/endpoint_lookup.rb
dhs-1.0.0 lib/dhs/concerns/item/endpoint_lookup.rb