Project

lupo

0.01
No commit activity in last 3 years
No release in over 3 years
Adds an #each method to your objects
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3.5

Runtime

~> 0.1.4
 Project Readme

lupo

Gem Version Build Status Dependency Status Code Climate Coverage Status

Usage

# 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

Credits

Contributing

See CONTRIBUTING.md for details.

Copyright

Copyright © 2013 Martin Gamsjaeger (snusnu). See LICENSE for details.