Class Virtus::AttributeSet
In: lib/virtus/attribute_set.rb
Parent: Module

A set of Attribute objects

Methods

<<   []   []=   coerce   create   define_reader_method   define_writer_method   each   finalize   get   merge   new   reset   set   set_defaults  

Included Modules

Enumerable

Public Class methods

Initialize an AttributeSet

@param [AttributeSet] parent @param [Array] attributes

@return [undefined]

@api private

Public Instance methods

Adds an attribute to the set

@example

  attribute_set << attribute

@param [Attribute] attribute

@return [self]

@api public

Get an attribute by name

@example

  attribute_set[:name]  # => Attribute object

@param [Symbol] name

@return [Attribute]

@api public

Set an attribute by name

@example

  attribute_set[:name] = attribute

@param [Symbol] name @param [Attribute] attribute

@return [Attribute]

@api public

Coerce attributes received to a hash

@return [Hash]

@api private

Defines an attribute reader method

@param [Attribute] attribute @param [Symbol] method_name @param [Symbol] visibility

@return [undefined]

@api private

Defines an attribute writer method

@param [Attribute] attribute @param [Symbol] method_name @param [Symbol] visibility

@return [undefined]

@api private

Iterate over each attribute in the set

@example

  attribute_set = AttributeSet.new(attributes, parent)
  attribute_set.each { |attribute| ... }

@yield [attribute]

@yieldparam [Attribute] attribute

  each attribute in the set

@return [self]

@api public

@api private

Get values of all attributes defined for this class, ignoring privacy

@return [Hash]

@api private

Adds the attributes to the set

@example

  attribute_set.merge(attributes)

@param [Array<Attribute>] attributes

@return [self]

@api public

Reset the index when the parent is updated

@return [self]

@api private

Mass-assign attribute values

@see Virtus::InstanceMethods#attributes=

@return [Hash]

@api private

Set default attributes

@return [self]

@api private

[Validate]