Sha256: 69e8b210733ed0e3233174d6c50f11f92666af3bcbdeaff68f0b04cc74f40fc2

Contents?: true

Size: 589 Bytes

Versions: 1

Compression:

Stored size: 589 Bytes

Contents

require 'active_support/concern'
require 'active_support/inflector'

module Ripple
  module EmbeddedDocument
    # @private
    module Finders
      extend ActiveSupport::Concern

      module ClassMethods
        def instantiate(attrs)
          begin
            klass = attrs['_type'].present? ? attrs.delete('_type').constantize : self
          rescue NameError
            klass = self
          end
          klass.new.tap do |object|
            object.raw_attributes = attrs
            object.changed_attributes.clear
          end
        end
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
seomoz-ripple-1.0.0.pre lib/ripple/embedded_document/finders.rb