class SoberSwag::Nodes::Attribute
This is a node for one attribute of an object. An object type is represented by a `SoberSwag::Nodes::Object` full of these keys.
Attributes
@return [Symbol]
@return [Hash] the metadata for this attribute.
@return [Boolean] true if this attribute must be set, false otherwise.
@return [Class] the type of this attribute
Public Class Methods
@param key [Symbol] the key of this attribute @param required [Boolean] if this attribute must be set or not @param value [Class] the type of this attribute @param meta [Hash] the metadata associated with this attribute
# File lib/sober_swag/nodes/attribute.rb, line 14 def initialize(key, required, value, meta = {}) @key = key @required = required @value = value @meta = meta end
Public Instance Methods
@see SoberSwag::Nodes::Base#cata
# File lib/sober_swag/nodes/attribute.rb, line 64 def cata(&block) block.call( self.class.new( key, required, value.cata(&block), meta ) ) end
Deconstruct into the {#key}, {#required}, {#value}, and {#meta} attributes of this {Attribute} object.
@return [Array(Symbol, Boolean, Class, Hash)] the attributes of this object
# File lib/sober_swag/nodes/attribute.rb, line 26 def deconstruct [key, required, value, meta] end
Deconstructs into {#key}, {#required}, {#value}, and {#meta} attributes, as a hash with the attribute names as the keys.
@param _keys [void] ignored @return [Hash] the attributes as keys.
# File lib/sober_swag/nodes/attribute.rb, line 36 def deconstruct_keys(_keys) { key: key, required: required, value: value, meta: meta } end
@see SoberSwag::Nodes::Base#map
# File lib/sober_swag/nodes/attribute.rb, line 58 def map(&block) self.class.new(key, required, value.map(&block), meta) end