Class: ReeDto::DtoCollection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb

Constant Summary collapse

LoadError =
Class.new(ArgumentError)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, contract, parent_class) ⇒ DtoCollection

Returns a new instance of DtoCollection.



14
15
16
17
18
19
# File 'lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb', line 14

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

Instance Attribute Details

#contractObject (readonly)

Returns the value of attribute contract.



11
12
13
# File 'lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb', line 11

def contract
  @contract
end

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb', line 11

def name
  @name
end

#parent_classObject (readonly)

Returns the value of attribute parent_class.



11
12
13
# File 'lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb', line 11

def parent_class
  @parent_class
end

Class Method Details

.filter(name, filter_proc) ⇒ Object



46
47
48
49
50
# File 'lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb', line 46

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

Instance Method Details

#==(other) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb', line 37

def ==(other)
  if other.is_a?(self.class)
    @list == other.instance_variable_get(:@list)
  else
    @list == other
  end
end

#each(&block) ⇒ Object



22
23
24
# File 'lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb', line 22

def each(&block)
  @list.each(&block)
end

#inspectObject



32
33
34
# File 'lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb', line 32

def inspect
  @list.inspect
end

#to_sObject



27
28
29
# File 'lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_collection.rb', line 27

def to_s
  inspect
end