Sha256: 31069ae7c59f6cf426f0beed3390ec5c06811d2033c4e919e2753cbff314b58a
Contents?: true
Size: 867 Bytes
Versions: 1
Compression:
Stored size: 867 Bytes
Contents
# frozen_string_literal: true require 'active_support/concern' require_relative './setup_context' module SnFoil module Contexts module ShowContext extend ActiveSupport::Concern included do include SetupContext end class_methods do def show(id:, user: nil, **options) new(user).show(**options, id: id) end end def setup_show_object(id: nil, object: nil, **options) raise ArgumentError, 'one of the following keywords is required: id, object' unless id || object options.merge! object: wrap_object(object || scope.resolve.find(id)) end def show(**options) options[:action] = :show options = setup_show_object(**options) authorize(options[:object], :show?, **options) unwrap_object options[:object] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
snfoil-0.3.0 | lib/sn_foil/contexts/show_context.rb |