Sha256: d31bdfc23e423cf616413c988081e869c34d33d4d0e28e802d98c05c635ef5f4
Contents?: true
Size: 739 Bytes
Versions: 12
Compression:
Stored size: 739 Bytes
Contents
module Coprl::Presenters::DSL::Components class Link < Typography VALID_TARGETS = %i[self blank].freeze attr_accessor :url, :text, :target def initialize(parent:, **attribs_, &block) super(type: :link, parent: parent, **attribs_, &block) @url = attribs_.delete(:url) @text = attribs_.delete(:text) { url } @target = validate_target(attribs_.delete(:target) { :self }) expand! end private def validate_target(value) target = value&.to_sym unless VALID_TARGETS.include?(target) raise Errors::ParameterValidation, "target must be one of #{VALID_TARGETS.join(', ')}" end target end end end
Version data entries
12 entries across 12 versions & 1 rubygems