lib/pupa/models/model.rb in pupa-0.0.13 vs lib/pupa/models/model.rb in pupa-0.1.0
- old
+ new
@@ -34,20 +34,20 @@
attr_reader :_id
# @return [Hash] The object's non-schema properties.
attr_reader :extras
# @return [String] The underscored, lowercase form of the object's class.
attr_accessor :_type
- # @return [Moped::BSON::Document,nil] The object's matching document in
+ # @return [BSON::Document,nil] The object's matching document in
# the database. Set before persisting the object to the database.
attr_accessor :document
dump :_id, :_type, :extras
end
module ClassMethods
# Declare which properties should be dumped to JSON after a scraping task
- # is complete. A subset of these properties will be imported to MongoDB.
+ # is complete. A subset of these will be imported to the database.
#
# @param [Array<Symbol>] the properties to dump to JSON
def dump(*attributes)
self.properties += attributes # use assignment to not overwrite the parent's attribute
end
@@ -127,13 +127,13 @@
end
end
# Sets the object's ID.
#
- # @param [String,Moped::BSON::ObjectId] id an ID
+ # @param [String,BSON::ObjectId] id an ID
def _id=(id)
- @_id = id.to_s # in case of Moped::BSON::ObjectId
+ @_id = id.to_s # in case of BSON::ObjectId
end
# Sets the extras.
#
# @param [Array] extras a list of extras
@@ -174,10 +174,10 @@
end
# Returns the object as a hash.
#
# @param [Boolean] persist whether the object is being persisted, validated,
- # or used as a MongoDB selector, in which case foreign objects (i.e. hints)
+ # or used as a database selector, in which case foreign objects (hints)
# are excluded
# @return [Hash] the object as a hash
def to_h(persist: false)
{}.tap do |hash|
(persist ? properties - foreign_objects : properties).each do |property|