Sha256: c03e5fa014d8dcb300b6d29ccd7345fdee3a5df5d9e769ffff62bad1d6ad7838
Contents?: true
Size: 557 Bytes
Versions: 3
Compression:
Stored size: 557 Bytes
Contents
module ModelMacros # Create a new microscope model def microscope(klass_name, options = {}, &block) spawn_model klass_name, ActiveRecord::Base do instance_exec(&block) if block acts_as_microscope options end end protected # Create a new model class def spawn_model(klass_name, parent_klass, &block) Object.instance_eval { remove_const klass_name } if Object.const_defined?(klass_name) Object.const_set(klass_name, Class.new(parent_klass)) Object.const_get(klass_name).class_eval(&block) if block_given? end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
microscope-1.1.1 | spec/support/macros/model_macros.rb |
microscope-1.1.0 | spec/support/macros/model_macros.rb |
microscope-1.0.1 | spec/support/macros/model_macros.rb |