Class: CustomElementsManifestParser::DataTypes::Attribute

Inherits:
BaseStruct
  • Object
show all
Defined in:
lib/custom_elements_manifest_parser/data_types/attribute.rb

Overview

Documents an "attribute" on a custom element.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#defaultString?

Returns - The default value of the attribute, if any. As attributes are always strings, this is the actual value, not a human readable description.

Returns:

  • (String, nil)

    - The default value of the attribute, if any. As attributes are always strings, this is the actual value, not a human readable description.



32
# File 'lib/custom_elements_manifest_parser/data_types/attribute.rb', line 32

attribute :default, Types::Strict::String.optional.meta(required: false)

#deprecatednil, ...

Returns - Whether the attribute is deprecated. If the value is a string, it's the reason for the deprecation.

Returns:

  • (nil, Boolean, String)

    - Whether the attribute is deprecated. If the value is a string, it's the reason for the deprecation.



46
# File 'lib/custom_elements_manifest_parser/data_types/attribute.rb', line 46

attribute :deprecated, Types::Strict::String.optional | Types::Strict::Bool.optional.meta(required: false)

#descriptionString?

Returns - A markdown description.

Returns:

  • (String, nil)
    • A markdown description.


17
# File 'lib/custom_elements_manifest_parser/data_types/attribute.rb', line 17

attribute :description, Types::Strict::String.optional.meta(required: false)

#fieldNameString?

Returns - The name of the field this attribute is associated with, if any.

Returns:

  • (String, nil)
    • The name of the field this attribute is associated with, if any.


36
# File 'lib/custom_elements_manifest_parser/data_types/attribute.rb', line 36

attribute :fieldName, Types::Strict::String.optional.meta(required: false)

#inheritedFromReference?

Returns - Reference to where it inherited its attribute.

Returns:

  • (Reference, nil)
    • Reference to where it inherited its attribute


21
# File 'lib/custom_elements_manifest_parser/data_types/attribute.rb', line 21

attribute :inheritedFrom, Types::Nominal::Any.optional.meta(required: false)

#resolveInitializerResolveInitializer?

Returns:



40
# File 'lib/custom_elements_manifest_parser/data_types/attribute.rb', line 40

attribute :resolveInitializer, Types::Nominal::Any.optional.meta(required: false)

#summaryString?

Returns - A markdown summary suitable for display in a listing.

Returns:

  • (String, nil)
    • A markdown summary suitable for display in a listing.


13
# File 'lib/custom_elements_manifest_parser/data_types/attribute.rb', line 13

attribute :summary, Types::Strict::String.optional.meta(required: false)

#typeType?

Returns - The type that the attribute will be serialized/deserialized as.

Returns:

  • (Type, nil)
    • The type that the attribute will be serialized/deserialized as.


25
# File 'lib/custom_elements_manifest_parser/data_types/attribute.rb', line 25

attribute :type, Types::Nominal::Any.optional.meta(required: false)

Instance Method Details

#visit(parser:) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/custom_elements_manifest_parser/data_types/attribute.rb', line 48

def visit(parser:)
  hash = {}
  hash[:inheritedFrom] = parser.data_types[:inherited_from].new(inheritedFrom).visit(parser: parser) unless inheritedFrom.nil?
  hash[:type] = parser.data_types[:type].new(type).visit(parser: parser) unless type.nil?
  hash[:resolveInitializer] = parser.data_types[:resolve_initializer].new(resolveInitializer).visit(parser: parser) unless resolveInitializer.nil?
  new(hash)
end