Permalink
Browse files

track a list of the accessors/attributes on the class

  • Loading branch information...
1 parent 825c689 commit 6d134e5c08952bce70bc108ca62a42c56358595d @justinfrench committed Apr 18, 2012
Showing with 10 additions and 1 deletion.
  1. +5 −0 lib/modelling.rb
  2. +5 −1 spec/modelling_spec.rb
View
@@ -32,6 +32,10 @@ def structs(*args)
def members
@members ||= {}
end
+
+ def accessors
+ @accessors ||= []
+ end
private
@@ -55,6 +59,7 @@ def generate_accessors(names_to_initializer)
end
def create_accessor(name)
+ accessors << name
instance_eval { attr_accessor name }
end
View
@@ -125,7 +125,11 @@ class LambdaTest
it 'doesnt fail when lambdas with no args are used' do
LambdaTest.new.lambda.should eq 'boo'
end
-
+
+ specify 'tracks list of accessors' do
+ User.accessors.should include :name, :age
+ end
+
context 'inheritence' do
let(:car) { Car.new }
let(:super_car) { SuperCar.new }

0 comments on commit 6d134e5

Please sign in to comment.