neo4j-meta_model 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +19 -2
  3. data/app/assets/javascripts/meta_model.js.coffee +132 -130
  4. data/app/controllers/neo4j/meta_model/application_controller.rb +14 -0
  5. data/app/controllers/neo4j/meta_model/meta/has_associations_controller.rb +46 -0
  6. data/app/controllers/neo4j/meta_model/meta/models_controller.rb +82 -0
  7. data/app/controllers/neo4j/meta_model/meta/properties_controller.rb +38 -0
  8. data/app/controllers/neo4j/meta_model/meta_controller.rb +9 -0
  9. data/app/controllers/neo4j/meta_model/models_controller.rb +71 -0
  10. data/app/helpers/neo4j/meta_model/application_helper.rb +12 -0
  11. data/app/helpers/neo4j/meta_model/model_helper.rb +12 -0
  12. data/app/models/concerns/neo4j/meta_model/model_base.rb +45 -0
  13. data/app/models/neo4j/meta_model/has_association.rb +48 -0
  14. data/app/models/neo4j/meta_model/meta_model_base.rb +9 -0
  15. data/app/models/neo4j/meta_model/model.rb +53 -0
  16. data/app/models/neo4j/meta_model/property.rb +13 -0
  17. data/app/serializers/neo4j/meta_model/has_association_serializer.rb +15 -0
  18. data/app/serializers/neo4j/meta_model/model_serializer.rb +13 -0
  19. data/app/serializers/neo4j/meta_model/property_serializer.rb +8 -0
  20. data/app/views/{meta_model → neo4j/meta_model}/meta/associations/index.html.slim +0 -0
  21. data/app/views/{meta_model → neo4j/meta_model}/meta/index.html.slim +0 -0
  22. data/app/views/{meta_model → neo4j/meta_model}/meta/models/edit.html.slim +0 -0
  23. data/app/views/{meta_model → neo4j/meta_model}/models/_form.html.slim +16 -8
  24. data/app/views/{meta_model → neo4j/meta_model}/models/_has_many_association.html.slim +0 -0
  25. data/app/views/{meta_model → neo4j/meta_model}/models/_record_details.html.slim +0 -0
  26. data/app/views/{meta_model → neo4j/meta_model}/models/edit.html.slim +0 -0
  27. data/app/views/{meta_model → neo4j/meta_model}/models/index.html.slim +0 -0
  28. data/app/views/{meta_model → neo4j/meta_model}/models/meta_index.html.slim +0 -0
  29. data/app/views/{meta_model → neo4j/meta_model}/models/new.html.slim +0 -0
  30. data/app/views/{meta_model → neo4j/meta_model}/models/show.html.slim +0 -0
  31. data/config/routes.rb +1 -1
  32. data/lib/meta_models.rb +9 -7
  33. data/lib/neo4j/meta_model.rb +6 -0
  34. data/lib/neo4j/meta_model/engine.rb +25 -0
  35. data/lib/neo4j/meta_model/version.rb +5 -0
  36. data/test/dummy/config/application.rb +1 -1
  37. metadata +31 -31
  38. data/app/controllers/meta_model/application_controller.rb +0 -12
  39. data/app/controllers/meta_model/meta/has_associations_controller.rb +0 -44
  40. data/app/controllers/meta_model/meta/models_controller.rb +0 -80
  41. data/app/controllers/meta_model/meta/properties_controller.rb +0 -36
  42. data/app/controllers/meta_model/meta_controller.rb +0 -7
  43. data/app/controllers/meta_model/models_controller.rb +0 -69
  44. data/app/helpers/meta_model/application_helper.rb +0 -10
  45. data/app/helpers/meta_model/model_helper.rb +0 -10
  46. data/app/models/concerns/meta_model/model_base.rb +0 -43
  47. data/app/models/meta_model/has_association.rb +0 -46
  48. data/app/models/meta_model/meta_model_base.rb +0 -7
  49. data/app/models/meta_model/model.rb +0 -51
  50. data/app/models/meta_model/property.rb +0 -11
  51. data/app/serializers/meta_model/has_association_serializer.rb +0 -13
  52. data/app/serializers/meta_model/model_serializer.rb +0 -11
  53. data/app/serializers/meta_model/property_serializer.rb +0 -6
  54. data/lib/meta_model.rb +0 -4
  55. data/lib/meta_model/engine.rb +0 -23
  56. data/lib/meta_model/version.rb +0 -3
@@ -1,46 +0,0 @@
1
- module MetaModel
2
- class HasAssociation
3
- include Neo4j::ActiveRel
4
-
5
- from_class 'MetaModel::Model'
6
- to_class 'MetaModel::Model'
7
- type 'has_association_to'
8
-
9
-
10
- # one_to_many refers to from_class has_many to_classes
11
- # many_to_one refers to from_class has_one to_class
12
- property :join_type, type: String
13
- validates_inclusion_of :join_type, :in => %w( many_to_one one_to_many many_to_many )
14
-
15
- # Name of associations on each side
16
- property :name, type: String
17
- property :opposite_name, type: String
18
-
19
- property :relationship_type, type: String
20
-
21
- def from_model
22
- from_node
23
- end
24
-
25
- def to_model
26
- to_node
27
- end
28
-
29
- def from_model=(other)
30
- self.from_node = other
31
- end
32
-
33
- def to_model=(other)
34
- self.to_node = other
35
- end
36
-
37
- def from_model_id=(id)
38
- self.from_model = Model.find(id)
39
- end
40
-
41
- def to_model_id=(id)
42
- self.to_model = Model.find(id)
43
- end
44
-
45
- end
46
- end
@@ -1,7 +0,0 @@
1
- module MetaModel
2
- class MetaModelBase
3
- include Neo4j::ActiveNode
4
- include ActiveModel::Serialization
5
-
6
- end
7
- end
@@ -1,51 +0,0 @@
1
- module MetaModel
2
- class Model < MetaModelBase
3
- property :class_name, type: String
4
-
5
- has_one :out, :superclass_model, type: :inherits_from, model_class: 'MetaModel::Model'
6
-
7
- has_one :out, :id_property, type: :has_id_property, model_class: 'MetaModel::Property'
8
- has_many :out, :properties, type: :has_property, model_class: 'MetaModel::Property'
9
-
10
- has_many :both, :assocs, model_class: 'MetaModel::Model', rel_class: 'MetaModel::HasAssociation'
11
-
12
- before_destroy :destroy_properties
13
-
14
- def to_param
15
- self.class_name.tableize
16
- end
17
-
18
- # def property_ids
19
- # properties(:p).pluck(p: :uuid)
20
- # end
21
-
22
- def has_associations
23
- assocs.each_rel.to_a
24
- end
25
-
26
- def self.hierarchically
27
- Hash.new.tap do |result|
28
- model_parents = Hash[*all.query_as(:model).optional_match("model-[:inherits_from]->(parent)").pluck(:model, :parent).flatten]
29
-
30
- all.query_as(:model).where('NOT(model-[:inherits_from]->())').pluck(:model).each do |model|
31
- result[model] = {}
32
- end
33
-
34
- all.query_as(:model).match('p=model-[:inherits_from*1..]->()').pluck('nodes(p)').each do |path|
35
- path.reverse.inject(result) do |sub_result, model|
36
- sub_result[model] ||= {}
37
- sub_result[model]
38
- end
39
- end
40
-
41
- end
42
- end
43
-
44
- private
45
-
46
- def destroy_properties
47
- properties.each(&:destroy)
48
- id_property.try(:destroy)
49
- end
50
- end
51
- end
@@ -1,11 +0,0 @@
1
- module MetaModel
2
- class Property < MetaModelBase
3
- property :name, type: String
4
- property :type, type: String
5
-
6
- validates_inclusion_of :type, :in => %w( String DateTime Boolean Integer )
7
-
8
- has_one :in, :model, origin: :properties, model_class: 'MetaModel::Model'
9
-
10
- end
11
- end
@@ -1,13 +0,0 @@
1
- module MetaModel
2
- class HasAssociationSerializer < ActiveModel::Serializer
3
- attributes :id, :join_type, :name, :opposite_name, :relationship_type, :from_model, :to_model
4
-
5
- def from_model
6
- object.from_node.id
7
- end
8
-
9
- def to_model
10
- object.to_node.id
11
- end
12
- end
13
- end
@@ -1,11 +0,0 @@
1
- module MetaModel
2
- class ModelSerializer < ActiveModel::Serializer
3
- attributes :id, :class_name
4
-
5
- # embed :ids, include: true
6
-
7
- has_many :properties
8
- has_many :has_associations
9
- # has_one :superclass_model
10
- end
11
- end
@@ -1,6 +0,0 @@
1
- module MetaModel
2
- class PropertySerializer < ActiveModel::Serializer
3
- attributes :id, :name, :type
4
- end
5
- end
6
-
@@ -1,4 +0,0 @@
1
- require "meta_model/engine"
2
-
3
- module MetaModel
4
- end
@@ -1,23 +0,0 @@
1
- require 'active_model_serializers'
2
- require 'slim-rails'
3
- require 'ember-rails'
4
- require 'emblem/rails'
5
-
6
- # TODO: Isolate?
7
- ActiveModel::Serializer.setup do |config|
8
- config.embed = :ids
9
- config.embed_in_root = true
10
- end
11
-
12
- module MetaModel
13
- class Engine < ::Rails::Engine
14
- isolate_namespace MetaModel
15
-
16
- initializer :assets do |config|
17
- Rails.application.config.assets.precompile += %w( admin/models.js meta_model.js
18
- meta_model.css )
19
-
20
- Rails.application.config.assets.paths << "#{Rails.root}/vendor/assets/fonts"
21
- end
22
- end
23
- end
@@ -1,3 +0,0 @@
1
- module MetaModel
2
- VERSION = "0.0.1"
3
- end