Sha256: 5858aa61ac24371dab1275980c99b6edd4d62cc47155a738f6b2da8e06b13b87
Contents?: true
Size: 821 Bytes
Versions: 12
Compression:
Stored size: 821 Bytes
Contents
# frozen_string_literal: true require "stimulus_reflex/dataset" require "stimulus_reflex/utils/attribute_builder" class StimulusReflex::Element < OpenStruct include StimulusReflex::AttributeBuilder attr_reader :attrs, :dataset alias_method :data_attributes, :dataset delegate :signed, :unsigned, :numeric, :boolean, :data_attrs, to: :dataset def initialize(data = {}) @attrs = HashWithIndifferentAccess.new(data["attrs"] || {}) @dataset = StimulusReflex::Dataset.new(data) all_attributes = @attrs.merge(@dataset.attrs) super build_underscored(all_attributes) end def attributes @attributes ||= OpenStruct.new(build_underscored(attrs)) end def to_dom_id raise NoIDError.new "The element `morph` is called on must have a valid DOM ID" if id.blank? "##{id}" end end
Version data entries
12 entries across 12 versions & 1 rubygems