Sha256: 238aeba7c46da80204c69ebfeba7964dbe6ecc9f551343fb29bdea8c2c6bba39
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
module ActiveData module Model module Associations module Reflections class EmbedsAny < Base def self.build(target, generated_methods, name, options = {}, &block) if block options[:class] = proc do |reflection| superclass = reflection.options[:class_name].to_s.presence.try(:constantize) klass = Class.new(superclass || ActiveData.base_class) do include ActiveData::Model include ActiveData::Model::Associations include ActiveData::Model::Lifecycle include ActiveData::Model::Primary end target.const_set(name.to_s.classify, klass) klass.class_eval(&block) klass end end super end def klass @klass ||= if options[:class] options[:class].call(self) else super end end def inspect "#{self.class.name.demodulize}(#{klass})" end def embedded? true end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_data-1.1.1 | lib/active_data/model/associations/reflections/embeds_any.rb |