lib/characterizable.rb in characterizable-0.0.5 vs lib/characterizable.rb in characterizable-0.0.6

- old
+ new

@@ -103,12 +103,14 @@ @_characteristics ||= SurvivorHash.new end include Blockenspiel::DSL def has(name, options = {}, &block) characteristics[name] = Characteristic.new(self, name, options, &block) - if klass.respond_to? :attribute_methods_generated? and !klass.attribute_methods_generated? + begin # quacks like an activemodel - klass.define_attribute_methods + klass.define_attribute_methods if klass.respond_to?(:attribute_methods_generated?) and !klass.attribute_methods_generated? + rescue + # for example, if a table doesn't exist... just ignore it end klass.module_eval(%{ def #{name}_with_expire_snapshot=(new_#{name}) expire_snapshot! self.#{name}_without_expire_snapshot = new_#{name}