Sha256: dbe498778ffec57946aedcc4e9521f75531f3b629a417d4af9e072b40563f939

Contents?: true

Size: 686 Bytes

Versions: 2

Compression:

Stored size: 686 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Extensions #:nodoc:
    module Object #:nodoc:
      # This module converts objects into mongoid related objects.
      module Conversions #:nodoc:
        extend ActiveSupport::Concern
        module InstanceMethods
          # Converts this object to a hash of attributes
          def mongoidize
            self.raw_attributes
          end
        end

        module ClassMethods
          def set(value)
            value.respond_to?(:raw_attributes) ? value.raw_attributes : value
          end

          def get(value)
            value ? self.instantiate(value) : value
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
chhean-mongoid-2.0.1.beta1 lib/mongoid/extensions/object/conversions.rb
mongoid-2.0.0.beta.5 lib/mongoid/extensions/object/conversions.rb