Class: DocumentType

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document_id) ⇒ DocumentType

Returns a new instance of DocumentType.



47
48
49
# File 'lib/classiccms/models/base.rb', line 47

def initialize(document_id)
  @document_id
end

Instance Attribute Details

#document_idObject (readonly)

Returns the value of attribute document_id.



45
46
47
# File 'lib/classiccms/models/base.rb', line 45

def document_id
  @document_id
end

Class Method Details

.demongoize(object_id) ⇒ Object

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



55
56
57
58
59
60
61
62
# File 'lib/classiccms/models/base.rb', line 55

def demongoize(object_id)
  document = Document.where(:id => object_id).first
  if document != nil
    document.file
  else
    Dragonfly[:file].fetch_file(File.join(Dir.pwd, 'public/not_found.jpeg'))
  end
end

.evolve(object) ⇒ Object

Converts the object that was supplied to a criteria and converts it into a database friendly form.



72
73
74
75
76
77
# File 'lib/classiccms/models/base.rb', line 72

def evolve(object)
  case object
  when FileType then object.mongoize
  else object
  end
end

.mongoize(object_id) ⇒ Object

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



66
67
68
# File 'lib/classiccms/models/base.rb', line 66

def mongoize(object_id)
  object_id
end