Permalink
Browse files

Pre-release cleanup

  • Loading branch information...
1 parent cdcd599 commit e093d1b0a4789ca8a8c4f2dfb086528ce8f2b0a0 @delano committed Nov 30, 2009
Showing with 25 additions and 13 deletions.
  1. +15 −12 README.rdoc
  2. +4 −1 attic.gemspec
  3. +4 −0 lib/attic.rb
  4. +2 −0 try/X2_extending.rb
View
@@ -1,23 +1,27 @@
-= Attic - v0.4 ALPHA
+= Attic - v0.5
-A place for Ruby objects to hide instance variables.
-
-== Alpha Notice
-
-This library is fresh (est 2009-07-06) and barely tested. It's fun to use but not reliable yet.
+A place to hide private instance variables in your Ruby objects.
== Example
require 'attic'
- String.extend Attic
- String.attic :timestamp
+ class String
+ extend Attic
+ attic :timestamp
+ end
a = "anything"
a.timestamp = "1980-11-18"
- a.instance_variables # => []
- 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
@@ -29,7 +33,6 @@ Symbol and Fixnum objects do not have metaclasses so instance variables are hidd
Via Rubygems, one of:
$ gem install attic
- $ gem install delano-attic --source http://gems.github.com/
or via download:
* attic-latest.tar.gz[http://github.com/delano/attic/tarball/latest]
View
@@ -2,7 +2,7 @@
s.name = "attic"
s.rubyforge_project = "attic"
s.version = "0.4.0"
- s.summary = "A place for Ruby objects to hide instance variables."
+ s.summary = "A place to hide private instance variables in your Ruby objects."
s.description = s.summary
s.author = "Delano Mandelbaum"
s.email = "delano@solutious.com"
@@ -46,6 +46,9 @@
try/20_accessing_tryouts.rb
try/25_string_tryouts.rb
try/30_nometaclass_tryouts.rb
+ try/40_explicit_accessor_tryouts.rb
+ try/X1_metaclasses.rb
+ try/X2_extending.rb
)
s.has_rdoc = true
View
@@ -13,7 +13,11 @@ def attic_variables
self.class.attic_variables
end
alias_method :attic_vars, :attic_variables
+ def attic_variable? n
+ self.class.attic_variable? n
+ end
def attic_variable_set(n,v)
+ attic_variables << n unless attic_variable? n
if metaclass?
metaclass.instance_variable_set("@#{n}", v)
else
View
@@ -23,3 +23,5 @@ class C
p [a.andy, b.andy] # 1, 2
p [a.class.attic_vars, b.class.attic_vars, c.class.attic_vars]
+
+

0 comments on commit e093d1b

Please sign in to comment.