blob: 7d8a8a2f2b368cb3b2188021fbe2a1bd99d7af6b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
module OpenTox
# Ruby interface
# create default OpenTox classes (defined in opentox-client.rb)
# provides Mongoid's query and persistence methods
# http://mongoid.org/en/mongoid/docs/persistence.html
# http://mongoid.org/en/mongoid/docs/querying.html
CLASSES.each do |klass|
c = Class.new do
include OpenTox
include Mongoid::Document
include Mongoid::Timestamps
store_in collection: klass.downcase.pluralize
field :name, type: String
field :source, type: String
field :warnings, type: Array, default: []
def warn warning
$logger.warn warning
warnings << warning
end
end
OpenTox.const_set klass,c
end
end
|