README.tmpl in attributes-4.1.0 vs README.tmpl in attributes-5.0.0

- old
+ new

@@ -43,9 +43,66 @@ - getters acts as setters if an argument is given to them all this in < 100 lines of code HISTORY + 5.0.0 + - added support for block caching. for example + + - simple block caching: + + class Filter + attribute :process + end + + (( filter = Filter.new )).process{|line| line.upcase} + + lines.each do |line| + p filter.process.call(line) + end + + - using block caching to delay block evaluation/class-factory: + + module MigrationDSL + attribute :migration + + def migration_class + model = self + Class.new(::ActiveRecord::Migration) do + singleton_class = + class << self + self + end + singleton_class.module_eval{ attribute :model => model } + singleton_class.module_eval &model.migration + end + end + end + + class Table < ActiveRecord::Base + extend MigrationDSL + end + + class Jobs < Table + migration do + def up + create_table model.table_name, :primary_key => model.primary_key do |t| + t.column 'rockin', :text + end + end + + def down + create_table model.table_name + end + end + end + + ... + + JobsMigration = Jobs.migration_class + + - cleaned up some warnings under 'ruby -d' + 4.1.0 - 4.0.0 introduced a bug where a query (foo?) would not initialize a var - 4.1.0 fixes that 4.0.0