-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.rb
More file actions
45 lines (31 loc) · 799 Bytes
/
models.rb
File metadata and controls
45 lines (31 loc) · 799 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'neo4j'
class Appearance
include Neo4j::ActiveRel
property :position # Where in the talk the word appears
from_class 'Word'
to_class 'Talk'
type :APPEARED_IN
end
class Talk
include Neo4j::ActiveNode
# Properties
id_property :title
property :created_at
property :updated_at
# Associations
has_many :in, :words, model_class: :Word, rel_class: 'Appearance'
# Validations
validates :title, presence: true
end
class Word
include Neo4j::ActiveNode
# Properties
id_property :normalized_text
property :is_stop_word, type: Boolean, default: false
property :created_at
property :updated_at
# Associations
has_many :out, :appearances, model_class: :Talk, rel_class: 'Appearance'
# Validations
validates :normalized_text, presence: true
end