struct-alias_member

Build Status Gem Version

Description

Struct will be able to alias the members name.

Usage

Overview

require 'struct/alias_member'

BankAccount = Struct.new :name, :balance do
  alias_member :money, :balance
end

ac = BankAccount.new 'John', 100
ac.money          #=> 100
ac[:money]        #=> 100
ac[:money] = 999
ac.balance        #=> 999
ac.member? :money #=> true
ac.aliases        #=> {:money=>:balance}

Requirements

Install

$ gem install struct-alias_member

Link

License

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