-
Notifications
You must be signed in to change notification settings - Fork 274
/
Copy pathshared.rb
48 lines (40 loc) · 1.14 KB
/
shared.rb
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
46
47
48
module ActiveGraph
module Shared
extend ActiveSupport::Concern
extend ActiveModel::Naming
include ActiveModel::Conversion
begin
include ActiveModel::Serializers::Xml
rescue NameError; end # rubocop:disable Lint/HandleExceptions
include ActiveModel::Serializers::JSON
module ClassMethods
# This should be used everywhere. Should make it easy
# to support a driver-per-model system
def neo4j_query(*args)
ActiveGraph::Base.query(*args)
end
def new_query
ActiveGraph::Base.new_query
end
end
included do
self.include_root_in_json = ActiveGraph::Config.include_root_in_json
@_declared_properties ||= ActiveGraph::Shared::DeclaredProperties.new(self)
def self.i18n_scope
:neo4j
end
def self.inherited(other)
attributes.each_pair do |k, v|
other.inherit_property k.to_sym, v.clone, declared_properties[k].options
end
super
end
end
def declared_properties
self.class.declared_properties
end
def neo4j_query(*args)
self.class.neo4j_query(*args)
end
end
end