Flyweight

A tiny template for the “Flyweight Pattern”

This project is maintained by kachick

flyweight

Build Status Gem Version

Description

A tiny template for the "Flyweight Pattern".

Features

Usage

class Material
  include Flyweight

  def initialize(looks, price)
    @looks, @price = looks, price
  end
end

a = Material.intern :metal, 2000
b = Material.intern :metal, 2000
c = Material.new    :metal, 2000
d = Material.intern :paper, 50
a == b     #=> true
a.equal? b #=> true
a == c     #=> true
a.equal? c #=> false
a == d     #=> false
a.equal? d #=> false

Requirements

Install

$ gem install flyweight

Link

License

The MIT X11 License
Copyright (c) 2012 Kenichi Kamiya
See MIT-LICENSE for further details.