Skip to content

Commit

Permalink
fixes caching error
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffp committed May 29, 2010
1 parent fa629ea commit 113eb4f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/enumerated_attribute/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def create_enumerated_attribute(*args, &block)
write_enumerated_attribute(config.attr_symbol, z[index > 0 ? index-1 : z.size-1])
end
end
refresh_enumerated_attributes
end
end

Expand Down
3 changes: 3 additions & 0 deletions lib/enumerated_attribute/attribute/class_methods.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module EnumeratedAttribute
module Attribute
module ClassMethods
def refresh_enumerated_attributes
@all_enumerated_attributes_cache = nil
end
def enumerated_attributes(all=true)
return @enumerated_attributes unless all
return @all_enumerated_attributes_cache if @all_enumerated_attributes_cache
Expand Down
11 changes: 11 additions & 0 deletions spec/poro_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
end
end

describe "enumerated_attributes caching" do
class Impl1
enum_attr :enum1, %w(e1 e2)
enumerated_attributes
enum_attr :enum2, %w(e3 e4)
end
it "should have enum2 described even though enumerated_attributes cached state" do
obj = Impl1.new
lambda { obj.enum2 = :e3 }.should_not raise_exception
end
end
describe "Plural" do
it "should have plural accessor :boxes for :box" do
p=Plural.new
Expand Down

0 comments on commit 113eb4f

Please sign in to comment.