Sha256: b4ef69b0d98dcccdd5c3ce1595d8dbbe7932c61790d3605d9f3350eb207ec7c7

Contents?: true

Size: 465 Bytes

Versions: 1

Compression:

Stored size: 465 Bytes

Contents

# frozen_string_literal: true

module ActionLink
  # Extracts a model from the provided model options.
  class Model
    include Calls

    option :manual_model
    option :url

    def call
      model.respond_to?(:model_name) ||
        raise(MissingModelError, "Model `#{model.inspect}` must respond to #model_name")

      model
    end

    private

    def model
      return manual_model if manual_model

      url.last if url.is_a?(Array)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
action_link-0.1.1 lib/action_link/model.rb