examples/class_attribute.rb in sync_attr-0.0.1 vs examples/class_attribute.rb in sync_attr-0.1.0

- old
+ new

@@ -1,11 +1,11 @@ # Class Attribute Example # require 'sync_attr' # Sample class with lazy initialized Synchronized Class Attributes -def Person +class Person include SyncAttr # Thread safe Class Attribute reader for name # Sets :name only when it is first called # Ideal for when name is loaded after startup from a database or config file @@ -18,14 +18,13 @@ sync_cattr_accessor :age do 21 end end -person = Person.new -puts "The person is #{person.name} with age #{person.age}" +puts "The person is #{Person.name} with age #{Person.age}" -person.age = 22 -puts "The person is #{person.name} now has age #{person.age}" +Person.age = 22 +puts "The person is #{Person.name} now has age #{Person.age}" -person.age = Proc.new {|age| age += 1 } -puts "The person is #{person.name} now has age #{person.age}" +Person.age = Proc.new {|age| age += 1 } +puts "The person is #{Person.name} now has age #{Person.age}"