Sha256: 0403529dada2422777daca473141f9e579bc464b84ab2768e28e26626b07cc41

Contents?: true

Size: 659 Bytes

Versions: 5

Compression:

Stored size: 659 Bytes

Contents

require_relative "./collection_filter"

class ReeDto::DtoCollection
  include Enumerable

  LoadError = Class.new(ArgumentError)

  attr_reader :name, :contract, :parent_class

  contract Symbol, Any, Any => Any
  def initialize(name, contract, parent_class)
    @parent_class = parent_class
    @contract = contract
    @name = name
    @list = []
  end

  contract Optblock => Any
  def each(&block)
    @list.each(&block)
  end

  contract None => Integer
  def size
    @list.size
  end

  class << self
    def filter(name, filter_proc)
      define_method name do
        ReeDto::CollectionFilter.new(self, name, filter_proc)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ree_lib-1.0.113 lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb
ree_lib-1.0.112 lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb
ree_lib-1.0.111 lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb
ree_lib-1.0.110 lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb
ree_lib-1.0.109 lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb