Stannum

A library for defining and validating data structures.

Module: Stannum::Entities::Properties

Parent Namespace
Stannum::Entities
Defined In
lib/stannum/entities/properties.rb

Table Of Contents

Overview

Abstract module for handling heterogenous entity properties.

This module provides a base for accessing and mutating entity properties such as attributes and associations.

Back To Top

Instance Methods

#==(other) =>

Compares the entity with the other object.

The other object must be an instance of the current class. In addition, the properties hashes of the two objects must be equal.

Returns

#[](property) => Object

Retrieves the property with the given key.

Parameters

Returns

Raises

#[]=(property, value) => Object

Sets the given property to the given value.

Parameters

Raises

#assign_properties(properties) => Object

Also known as: assign

Updates the struct’s properties with the given values.

This method is used to update some (but not all) of the properties of the struct. For each key in the hash, it calls the corresponding writer method with the value for that property. If the value is nil, this will set the property value to the default for that property.

Any properties that are not in the given hash are unchanged.

If the properties hash includes any keys that do not correspond to an property, the struct will raise an error.

Parameters

Raises

See Also

#initialize(**properties) => Object

Parameters

#inspect => String

Returns

#inspect_with_options(**options) => String

Parameters

Options Hash (options)

Returns

#properties => Hash<String, Object>

Collects the entity properties.

Returns

#properties=(properties) => Object

Replaces the entity’s properties with the given values.

This method is used to update all of the properties of the entity. For each property, the writer method is called with the value from the hash, or nil if the corresponding key is not present in the hash. Any nil or missing values set the property value to that property’s default value, if any.

If the properties hash includes any keys that do not correspond to a valid property, the entity will raise an error.

Parameters

Raises

See Also

#to_h => Hash<String, Object>

Returns a Hash representation of the entity.

Returns

See Also

Back To Top


Back to Documentation | Versions | 0.4 | Reference | Stannum | Stannum::Entities