Class: Structish::Array

Inherits:
Array
  • Object
show all
Includes:
Validations
Defined in:
lib/structish/array.rb

Instance Method Summary collapse

Methods included from Validations

included

Methods inherited from Array

#to_structish

Constructor Details

#initialize(constructor) ⇒ Array

Returns a new instance of Array.

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
# File 'lib/structish/array.rb', line 6

def initialize(constructor)
  raise(ArgumentError, "Only array-like objects can be used as constructors for Structish::Array") unless constructor.class <= ::Array
  validate_structish(constructor)
  if self.class.compact?
    super(constructor.compact)
  else
    super(constructor)
  end
end

Instance Method Details

#<<(entry) ⇒ Object



16
17
18
19
# File 'lib/structish/array.rb', line 16

def <<(entry)
  super(entry)
  validate_structish(self)
end