Sha256: 7fe75b8c5bb0c5d667a79c1fa10c47e8a3aea0d71033b999a2975d359332a11d
Contents?: true
Size: 378 Bytes
Versions: 10
Compression:
Stored size: 378 Bytes
Contents
# frozen_string_literal: true module ModelMacros # Create a new model class def spawn_model(klass_name, parent_klass = ActiveRecord::Base, &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
10 entries across 10 versions & 1 rubygems