Sha256: 8be3e271f001511ee87aa79d49892c27e371c9d4b054df433c20ce1d41278b3d

Contents?: true

Size: 606 Bytes

Versions: 17

Compression:

Stored size: 606 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:

  # Instantiates documents that came from the database.
  module Factory

    def from_db_with_custom_fields(klass, attributes = {})
      if klass.with_custom_fields?
        klass.klass_with_custom_fields(attributes['custom_fields_recipe'])
      end
      from_db_without_custom_fields(klass, attributes)
    end

    # equivalent for "alias_method_chain :from_db, :custom_fields"
    alias_method :from_db_without_custom_fields, :from_db unless method_defined?(:from_db_without_custom_fields)
    alias_method :from_db, :from_db_with_custom_fields

  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
custom_fields-2.1.0 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.1.0.rc2 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.1.0.rc1 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.1.0.rc lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.0.0.rc13 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.0.0.rc12 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.0.0.rc11 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.0.0.rc10 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.0.0.rc9 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.0.0.rc8 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.0.0.rc7 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.0.0.rc6 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.0.0.rc5 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.0.0.rc4 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.0.0.rc3 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.0.0.rc2 lib/custom_fields/extensions/mongoid/factory.rb
custom_fields-2.0.0.rc1 lib/custom_fields/extensions/mongoid/factory.rb