Class: Monolens::Type::Array
- Inherits:
-
Object
- Object
- Monolens::Type::Array
- Includes:
- ErrorHandling
- Defined in:
- lib/monolens/type/array.rb
Class Method Summary collapse
Instance Method Summary collapse
- #===(instance) ⇒ Object
- #dress(instance, registry, &block) ⇒ Object
-
#initialize(item_type) ⇒ Array
constructor
A new instance of Array.
Methods included from ErrorHandling
Constructor Details
#initialize(item_type) ⇒ Array
Returns a new instance of Array.
6 7 8 |
# File 'lib/monolens/type/array.rb', line 6 def initialize(item_type) @item_type = item_type end |
Class Method Details
Instance Method Details
#===(instance) ⇒ Object
20 21 22 23 24 |
# File 'lib/monolens/type/array.rb', line 20 def ===(instance) instance.is_a?(::Enumerable) && instance.all?{|item| @item_type === item } end |
#dress(instance, registry, &block) ⇒ Object
14 15 16 17 18 |
# File 'lib/monolens/type/array.rb', line 14 def dress(instance, registry, &block) fail!("Array expected, got #{instance.class}", &block) unless instance.is_a?(::Array) instance.map{|item| @item_type.dress(item, registry, &block) } end |