Class: Vinery::Collection

Inherits:
Array
  • Object
show all
Defined in:
lib/vinery/collection.rb

Overview

Public: An array-like object that contains Records. This class inherits from Array.

Examples

collection = Collection.new

collection.add(record1)

collection << record2

collection = Collection.new([record1, record2, record3])

Instance Method Summary collapse

Instance Method Details

#add(record) ⇒ Object Also known as: <<

Public: Appends a new Record to the end of a Collection.

record - The Record to be appended to the end of the Collection.

Examples

collection.push(record)

Returns the array of Records.

Raises:

  • (TypeError)


24
25
26
27
# File 'lib/vinery/collection.rb', line 24

def add(record)
  raise TypeError, "the object you're tyring to add is not a Record" unless record.is_a? Record
  super(record)
end