Sha256: 64aff5f405c90c81193c534a08e39f9e68460cdb81058131194b90cfbb85b623
Contents?: true
Size: 581 Bytes
Versions: 3
Compression:
Stored size: 581 Bytes
Contents
module ModelMacros # Create a new Emojimmy-powered model def spawn_emojimmy_model(klass_name, options = {}, &block) spawn_model klass_name do stores_emoji_characters options instance_exec(&block) if block end end protected # 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
emojimmy-0.1.3 | spec/support/macros/model_macros.rb |
emojimmy-0.1.2 | spec/support/macros/model_macros.rb |
emojimmy-0.1.1 | spec/support/macros/model_macros.rb |