Module: Virtus::Attribute::Collection::MemberCoercion

Included in:
Array, Set
Defined in:
lib/virtus/attribute/collection.rb

Overview

Default coercion method for collection members used by Array and Set

Instance Method Summary collapse

Instance Method Details

#coerce_and_append_member(collection, entry) ⇒ Array, Set

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Coerce a member of a source collection and append it to the target collection

Parameters:

  • collection (Array, Set)

    target collection to which the coerced member should be appended

  • entry (Object)

    the member that should be coerced and appended

Returns:

  • (Array, Set)

    collection with the coerced member appended to it



109
110
111
# File 'lib/virtus/attribute/collection.rb', line 109

def coerce_and_append_member(collection, entry)
  collection << @member_type_instance.coerce(entry)
end