Sha256: d99313937a11f2e74a57e8c8d91b8b6ad309aada430f8417825c6cc2c89eb64c
Contents?: true
Size: 733 Bytes
Versions: 5
Compression:
Stored size: 733 Bytes
Contents
# encoding: utf-8 module Mongoid #:nodoc: module Associations #:nodoc: class EmbedsMany < Proxy def build_with_custom_field_settings(attrs = {}, type = nil) document = build_without_custom_field_settings(attrs, type) if @association_name.ends_with?('_custom_fields') document.class_eval <<-EOV self.associations = {} # prevent associations to be nil embedded_in :#{@parent.class.to_s.underscore}, :inverse_of => :#{@association_name} EOV document.send(:set_unique_name!) document.send(:set_alias) end document end alias_method_chain :build, :custom_field_settings end end end
Version data entries
5 entries across 5 versions & 1 rubygems