Sha256: 7bace7a5465cb70d44d0c78da1f2c13a16303678cc89d73f7fd6be50d633060a
Contents?: true
Size: 836 Bytes
Versions: 49
Compression:
Stored size: 836 Bytes
Contents
# frozen_string_literal: true module Ariadne # Conditionally renders a `Ariadne::BaseComponent` around the given content. If the given condition # is true, a `Ariadne::BaseComponent` will render around the content. If the condition is false, only # the content is rendered. class ConditionalWrapper < Ariadne::BaseComponent # @param condition [Boolean] Whether or not to wrap the content in a `Ariadne::BaseComponent`. # @param base_component_arguments [Hash] The arguments to pass to `Ariadne::BaseComponent`. def initialize(condition:, **base_component_arguments) @condition = condition @base_component_arguments = base_component_arguments end def call return content unless @condition BaseComponent.new(**@base_component_arguments).render_in(self) { content } end end end
Version data entries
49 entries across 49 versions & 1 rubygems