2,875
edits
(Add SelectManyEnumerator) |
No edit summary |
||
Line 1: | Line 1: | ||
-- Helper Functions -- | |||
local function isType(obj, class) | |||
local mt = getmetatable(obj) | |||
while mt do | |||
if mt == class then | |||
return true | |||
end | |||
mt = getmetatable(mt) | |||
end | |||
return false | |||
end | |||
-- BASE ENUMERATOR CLASS -- | -- BASE ENUMERATOR CLASS -- | ||
--enumerable = {} | --enumerable = {} | ||
Line 75: | Line 87: | ||
return TableEnumerator.new(self.tbl) | return TableEnumerator.new(self.tbl) | ||
end | end | ||
end | end | ||
Line 210: | Line 221: | ||
local sourceTable = self.selector(current, self.position) | local sourceTable = self.selector(current, self.position) | ||
-- We need to turn the nested table into an enumerator | if not isType(sourceTable, Enumerator) then | ||
-- We need to turn the nested table into an enumerator | |||
self.sourceEnumerator = TableEnumerator.new(sourceTable):getEnumerator() | |||
else | |||
self.sourceEnumerator = sourceTable | |||
end | |||
self.state = -4 -- signal to get next item | self.state = -4 -- signal to get next item | ||
else | else |
edits