Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
48 lines (28 sloc) 1.06 KB

Attic - v0.5

A place to hide private instance variables in your Ruby objects.

Example

require 'attic'

class String
  extend Attic
  attic :timestamp
end

a = "anything"
a.timestamp = "1980-11-18"
a.instance_variables                      # => []
a.timestamp                               # 1980-11-18

a.attic_variables                         # => [:timestamp]

a.attic_variable_set :tags, [:a, :b, :c]
a.attic_variable_get :tags                # [:a, :b, :c]

a.attic_variables                         # => [:timestamp, :tags]

Some objects have no metaclasses

Symbol and Fixnum objects do not have metaclasses so instance variables are hidden in the object itself.

Installation

Via Rubygems, one of:

$ gem install attic

or via download:

Credits

  • Delano (@solutious.com)

License

See: LICENSE.txt