Sha256: 58d0520e5ff3b41102f102ac554f9e422f5fb348a0a66e280a511f014be8d94a

Contents?: true

Size: 347 Bytes

Versions: 14

Compression:

Stored size: 347 Bytes

Contents

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

14 entries across 14 versions & 1 rubygems

Version Path
activerecord_json_validator-1.2.0 spec/support/macros/model_macros.rb
activerecord_json_validator-1.1.0 spec/support/macros/model_macros.rb
activerecord_json_validator-1.0.0 spec/support/macros/model_macros.rb
activerecord_json_validator-0.5.1 spec/support/macros/model_macros.rb
activerecord_json_validator-0.5 spec/support/macros/model_macros.rb
activerecord_json_validator-0.4.2 spec/support/macros/model_macros.rb
activerecord_json_validator-0.4.1 spec/support/macros/model_macros.rb
activerecord_json_validator-0.4 spec/support/macros/model_macros.rb
activerecord_json_validator-0.3 spec/support/macros/model_macros.rb
activerecord_json_validator-0.2 spec/support/macros/model_macros.rb
activerecord_json_validator-0.1.3 spec/support/macros/model_macros.rb
activerecord_json_validator-0.1.2 spec/support/macros/model_macros.rb
activerecord_json_validator-0.1.1 spec/support/macros/model_macros.rb
activerecord_json_validator-0.1 spec/support/macros/model_macros.rb