Class: ImageField

Inherits:
Object
  • Object
show all
Defined in:
lib/classiccms/custom.rb

Class Method Summary collapse

Class Method Details

.demongoize(object) ⇒ Object

Get the object as it was stored in the database, and instantiate this custom class from it.



8
9
10
# File 'lib/classiccms/custom.rb', line 8

def demongoize(object)
  Image.find(object).file
end

.mongoize(object) ⇒ Object

Takes any possible object and converts it to how it would be stored in the database.



14
15
16
17
18
19
# File 'lib/classiccms/custom.rb', line 14

def mongoize(object)
  case object
  when BSON::ObjectId then object
  else BSON::ObjectId(object)
  end
end