Class Class
In: lib/merb-core/core_ext/class.rb
Parent: Object

Allows attributes to be shared within an inheritance hierarchy, but where each descendant gets a copy of their parents’ attributes, instead of just a pointer to the same. This means that the child can add elements to, for example, an array without those additions being shared with either their parent, siblings, or children, which is unlike the regular class-level attributes that are shared across the entire hierarchy.

Methods

Constants

EMPTY_INHERITABLE_ATTRIBUTES = {}.freeze unless const_defined?(:EMPTY_INHERITABLE_ATTRIBUTES)   Prevent this constant from being created multiple times

External Aliases

inherited -> inherited_without_inheritable_attributes

Public Instance methods

Defines class-level (and optionally instance-level) attribute accessor.

Parameters

*syms<Array>:Array of attributes to define accessor for.

Options

:instance_writer<Boolean>:if true, instance-level attribute writer is defined.

Defines class-level and instance-level attribute reader.

Parameters

*syms<Array>:Array of attributes to define reader for.

Defines class-level (and optionally instance-level) attribute writer.

Parameters

*syms<Array>:Array of attributes to define writer for.

Options

:instance_writer<Boolean>:if true, instance-level attribute writer is defined.

Defines class-level inheritable attribute accessor. Attributes are available to subclasses, each subclass has a copy of parent‘s attribute.

Parameters

*syms<Array>:Array of attributes to define inheritable accessor for.

Options

:instance_writer<Boolean>:if true, instance-level inheritable attribute writer is defined.

Defines class-level inheritable array accessor. Arrays are available to subclasses, each subclass has a copy of parent‘s array. Difference between other inheritable attributes is that array is recreated every time it is written.

Parameters

*syms<Array>:Array of array attribute names to define inheritable accessor for.

Options

:instance_writer<Boolean>:if true, instance-level inheritable array attribute writer is defined.

Defines class-level inheritable array writer. Arrays are available to subclasses, each subclass has a copy of parent‘s array. Difference between other inheritable attributes is that array is recreated every time it is written.

Parameters

*syms<Array>:Array of array attribute names to define inheritable writer for.

Options

:instance_writer<Boolean>:if true, instance-level inheritable array attribute writer is defined.

Defines class-level inheritable hash accessor. Hashs are available to subclasses, each subclass has a copy of parent‘s hash. Difference between other inheritable attributes is that hash is recreated every time it is written.

Parameters

*syms<Array>:Array of hash attribute names to define inheritable accessor for.

Options

:instance_writer<Boolean>:if true, instance-level inheritable hash attribute writer is defined.

Defines class-level inheritable hash writer. Hashs are available to subclasses, each subclass has a copy of parent‘s hash. Difference between other inheritable attributes is that hash is recreated every time it is written.

Parameters

*syms<Array>:Array of hash attribute names to define inheritable writer for.

Options

:instance_writer<Boolean>:if true, instance-level inheritable hash attribute writer is defined.

Defines class-level inheritable attribute reader. Attributes are available to subclasses, each subclass has a copy of parent‘s attribute.

Parameters

*syms<Array>:Array of attributes to define inheritable reader for.

Defines class-level inheritable attribute writer. Attributes are available to subclasses, each subclass has a copy of parent‘s attribute.

Parameters

*syms<Array>:Array of attributes to define inheritable writer for.

Options

:instance_writer<Boolean>:if true, instance-level inheritable attribute writer is defined.

Returns

<Hash>:inheritable attributes hash or it‘s default value, new frozen Hash.

Reads value of inheritable attributes.

Returns

Inheritable attribute value. Subclasses store copies of values.

Resets inheritable attributes to either EMPTY_INHERITABLE_ATTRIBUTES if it is defined or it‘s default value, new frozen Hash.

Sets the array attribute which copy is available to subclasses.

Parameters

key<~to_s, String, Symbol>:inheritable attribute name
value<Array>:value of inheritable attribute

Notes

Inheritable array is re-created on each write.

Sets the attribute which copy is available to subclasses.

Parameters

key<~to_s, String, Symbol>:inheritable attribute name
value<Anything but Array or Hash>:value of inheritable attribute

Notes

If inheritable attributes storage has it‘s default value, a new frozen hash, it is set to new Hash that is not frozen.

Sets the hash attribute which copy is available to subclasses.

Parameters

key<~to_s, String, Symbol>:inheritable attribute name
value<Hash>:value of inheritable attribute

Notes

Inheritable hash is re-created on each write.

[Validate]