class Parlour::RbiGenerator::StructProp
Represents a T::Struct
property.
Constants
- EXTRA_PROPERTIES
The optional properties available on instances of this class.
Attributes
The name of this parameter, including any prefixes or suffixes such as +*+. @return [String]
This parameter's type. @return [Types::TypeLike, nil]
Public Class Methods
Create a new struct property.
For documentation on all optional properties, please refer to the documentation for T::Struct within the sorbet-runtime gem: github.com/sorbet/sorbet/blob/master/gems/sorbet-runtime/lib/types/props/_props.rb#L31-L106
@param name [String] The name of this property. @param type [String] This property's type. @return [void]
# File lib/parlour/rbi_generator/struct_prop.rb, line 33 def initialize(name, type, optional: nil, enum: nil, dont_store: nil, foreign: nil, default: nil, factory: nil, immutable: nil, array: nil, override: nil, redaction: nil) @name = name @type = type @optional = optional @enum = enum @dont_store = dont_store @foreign = foreign @default = default @factory = factory @immutable = immutable @array = array @override = override @redaction = redaction end
Public Instance Methods
Returns true if this instance is equal to another instance.
@param other [Object] The other instance. If this is not a {StructProp} (or a
subclass of it), this will always return false.
@return [Boolean]
# File lib/parlour/rbi_generator/struct_prop.rb, line 57 def ==(other) StructProp === other && name == other.name && type == other.type && optional == other.optional && enum == other.enum && dont_store == other.dont_store && foreign == other.foreign && default == other.default && factory == other.factory && immutable == other.immutable && array == other.array && override == other.override && redaction == other.redaction end
# File lib/parlour/rbi_generator/struct_prop.rb, line 134 def generalize_from_rbi! @type = TypeParser.parse_single_type(@type) if String === @type end
Returns the prop
call required to create this property. @return [String]
# File lib/parlour/rbi_generator/struct_prop.rb, line 122 def to_prop_call call = "prop :#{name}, #{String === @type ? @type : @type.generate_rbi}" EXTRA_PROPERTIES.each do |extra_property| value = send extra_property call += ", #{extra_property}: #{value}" unless value.nil? end call end