Sha256: 877ec2d8ce570c120d0eb22dd8bae281154580bab6526c0496bd5e35fd9a9ac1
Contents?: true
Size: 1.57 KB
Versions: 3
Compression:
Stored size: 1.57 KB
Contents
# frozen_string_literal: true module LinkedRails module Actions module DefaultActions module Update def has_resource_update_action(overwrite = {}) # rubocop:disable Naming/PredicateName has_resource_action(:update, update_resource_options(overwrite)) end def has_singular_update_action(overwrite = {}) # rubocop:disable Naming/PredicateName has_singular_action(:update, update_singular_options(overwrite)) end private def update_resource_options(overwrite = {}) default_update_options(overwrite) end def update_singular_options(overwrite = {}) default_update_options( url: -> { resource.singular_iri } ).merge(overwrite) end def default_update_options(overwrite = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength { form: -> { resource.class.try(:form_class) }, http_method: :put, image: 'fa-pencil-square-o', label: lambda { type = I18n.t("#{resource.class.name.tableize}.type", default: nil) type.present? ? I18n.t('edit_type', type: type) : I18n.t('update') }, policy: :update?, root_relative_iri: lambda { uri = resource.root_relative_iri.dup uri.path ||= '' uri.path += '/edit' uri.to_s }, type: Vocab.schema.UpdateAction, url: -> { resource.iri } }.merge(overwrite) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems