
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
= ValueObjectStruct
The ValueObjectStruct module uses Ruby's native Struct class to facilitate the declaration of immutable value object classes.
ValueObjectStruct classes are defined with ValueObjectStruct.class_with_attributes and a list of member attributes specified by Symbol. Like Struct classes, they may be assigned to a constant or variable, or used in a superclass declaration.
ValueObjectStruct instances are Struct instances with private attribute write access, including both named attribute writers and Hash or Array style bracketed subscript assignment. ValueObjectStruct instances created with ::value (as opposed to ::new or ::for_values) are frozen, so that attribute values may not be reassigned after initialization, even by private methods.
ValueObjectStruct instances do not enforce immutability of attribute values themselves, so it may be desirable to freeze mutable value types such as String, Array and Hash before using them to initialize an instance.
As Struct instances, ValueObjectStruct instances provide equality and hash semantics via #== and #hash. #empty? returns true for value object instances with no non-nil attribute values.
ValueObjectStruct instances provide an #attributes and #attribute method for compatibility with ActiveModel. #attributes returns a hash representation of attribute values. #attribute is an alias for #[].
== Example
class Address < ValueObjectStruct.class_with_attributes(:street,:zip); end address = Address.new(street: "123 Main", zip: 11211)
address.street = "123 Maple" # raises NoMethodError address[:street] = "456 Elm" # raises NoMethodError address[1] = "789 Pine" # raises NoMethodError
address == Address.new(street: "123 Main", zip: 11211) # => true address == Address.new(street: "123 Maple", zip: 11211) # => false
set = Set[address] set.include? Address.new(street: "123 Main", zip: 11211) # => true set.include? Address.new(street: "123 Main", zip: 11212) # => false
== Copyright
Copyright (c) 2012 Riley Lynch, Teleological Software, LLC. See LICENSE.txt for further details.
FAQs
Unknown package
We found that value_object_struct demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.