module SnFoil::Contexts::ShowContext

Public Instance Methods

setup_show(method = nil, **options, &block) click to toggle source
# File lib/sn_foil/contexts/show_context.rb, line 22
def setup_show(method = nil, **options, &block)
  raise ArgumentError, '#setup_show requires either a method name or a block' if method.nil? && block.nil?

  (@i_setup_show_hooks ||= []) << { method: method, block: block, if: options[:if], unless: options[:unless] }
end
setup_show_hooks() click to toggle source
# File lib/sn_foil/contexts/show_context.rb, line 35
def setup_show_hooks
  self.class.i_setup_show_hooks || []
end
setup_show_object(id: nil, object: nil, **options) click to toggle source
# File lib/sn_foil/contexts/show_context.rb, line 29
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
show(id:, entity: nil, **options) click to toggle source
# File lib/sn_foil/contexts/show_context.rb, line 18
def show(id:, entity: nil, **options)
  new(entity).show(**options, id: id)
end

Private Instance Methods

before_setup_show(**options) click to toggle source
# File lib/sn_foil/contexts/show_context.rb, line 53
def before_setup_show(**options)
  options = setup(**options)
  options = setup_hooks.reduce(options) { |opts, hook| run_hook(hook, opts) }
  options = setup_show(**options)
  setup_show_hooks.reduce(options) { |opts, hook| run_hook(hook, opts) }
end