# Remember that Enumerable#entries is part
# of ruby, so avoiding "entries" as the
# internal enumerable's name is a good idea
# if your enumerable is no array instance.
require 'lupo'
class TaskList
include Lupo.enumerable(:tasks)
def initialize(name, tasks)
@name, @tasks = name, tasks
end
end
list = TaskList.new('secret', %w[this and that])
list.each { |t| puts(t) } # => list
list.each.to_a # => ['this', 'and', 'that']
list.is_a?(Enumerable) # => true
list.methods.include?(:tasks) # => false
class ItemList
include Lupo.collection(:items)
end
list = ItemList.new(%w[this and that])
list.each { |i| puts(i) } # => list
list.each.to_a # => ['this', 'and', 'that']
list.is_a?(Enumerable) # => true
list.protected_methods.include?(:items) # => true
other = ItemList.new(%w[this and that])
# see equalizer for detailed docs
list.equal?(other) # => false
list.eql?(other) # => true
list == other # => true
See CONTRIBUTING.md for details.
Copyright © 2013 Martin Gamsjaeger (snusnu). See LICENSE for details.