Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

track a list of the accessors/attributes on the class

  • Loading branch information...
commit 6d134e5c08952bce70bc108ca62a42c56358595d 1 parent 825c689
@justinfrench authored
Showing with 10 additions and 1 deletion.
  1. +5 −0 lib/modelling.rb
  2. +5 −1 spec/modelling_spec.rb
View
5 lib/modelling.rb
@@ -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
6 spec/modelling_spec.rb
@@ -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 }
Please sign in to comment.
Something went wrong with that request. Please try again.