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.
- checksums.yaml +4 -4
- data/README.rdoc +19 -2
- data/app/assets/javascripts/meta_model.js.coffee +132 -130
- data/app/controllers/neo4j/meta_model/application_controller.rb +14 -0
- data/app/controllers/neo4j/meta_model/meta/has_associations_controller.rb +46 -0
- data/app/controllers/neo4j/meta_model/meta/models_controller.rb +82 -0
- data/app/controllers/neo4j/meta_model/meta/properties_controller.rb +38 -0
- data/app/controllers/neo4j/meta_model/meta_controller.rb +9 -0
- data/app/controllers/neo4j/meta_model/models_controller.rb +71 -0
- data/app/helpers/neo4j/meta_model/application_helper.rb +12 -0
- data/app/helpers/neo4j/meta_model/model_helper.rb +12 -0
- data/app/models/concerns/neo4j/meta_model/model_base.rb +45 -0
- data/app/models/neo4j/meta_model/has_association.rb +48 -0
- data/app/models/neo4j/meta_model/meta_model_base.rb +9 -0
- data/app/models/neo4j/meta_model/model.rb +53 -0
- data/app/models/neo4j/meta_model/property.rb +13 -0
- data/app/serializers/neo4j/meta_model/has_association_serializer.rb +15 -0
- data/app/serializers/neo4j/meta_model/model_serializer.rb +13 -0
- data/app/serializers/neo4j/meta_model/property_serializer.rb +8 -0
- data/app/views/{meta_model → neo4j/meta_model}/meta/associations/index.html.slim +0 -0
- data/app/views/{meta_model → neo4j/meta_model}/meta/index.html.slim +0 -0
- data/app/views/{meta_model → neo4j/meta_model}/meta/models/edit.html.slim +0 -0
- data/app/views/{meta_model → neo4j/meta_model}/models/_form.html.slim +16 -8
- data/app/views/{meta_model → neo4j/meta_model}/models/_has_many_association.html.slim +0 -0
- data/app/views/{meta_model → neo4j/meta_model}/models/_record_details.html.slim +0 -0
- data/app/views/{meta_model → neo4j/meta_model}/models/edit.html.slim +0 -0
- data/app/views/{meta_model → neo4j/meta_model}/models/index.html.slim +0 -0
- data/app/views/{meta_model → neo4j/meta_model}/models/meta_index.html.slim +0 -0
- data/app/views/{meta_model → neo4j/meta_model}/models/new.html.slim +0 -0
- data/app/views/{meta_model → neo4j/meta_model}/models/show.html.slim +0 -0
- data/config/routes.rb +1 -1
- data/lib/meta_models.rb +9 -7
- data/lib/neo4j/meta_model.rb +6 -0
- data/lib/neo4j/meta_model/engine.rb +25 -0
- data/lib/neo4j/meta_model/version.rb +5 -0
- data/test/dummy/config/application.rb +1 -1
- metadata +31 -31
- data/app/controllers/meta_model/application_controller.rb +0 -12
- data/app/controllers/meta_model/meta/has_associations_controller.rb +0 -44
- data/app/controllers/meta_model/meta/models_controller.rb +0 -80
- data/app/controllers/meta_model/meta/properties_controller.rb +0 -36
- data/app/controllers/meta_model/meta_controller.rb +0 -7
- data/app/controllers/meta_model/models_controller.rb +0 -69
- data/app/helpers/meta_model/application_helper.rb +0 -10
- data/app/helpers/meta_model/model_helper.rb +0 -10
- data/app/models/concerns/meta_model/model_base.rb +0 -43
- data/app/models/meta_model/has_association.rb +0 -46
- data/app/models/meta_model/meta_model_base.rb +0 -7
- data/app/models/meta_model/model.rb +0 -51
- data/app/models/meta_model/property.rb +0 -11
- data/app/serializers/meta_model/has_association_serializer.rb +0 -13
- data/app/serializers/meta_model/model_serializer.rb +0 -11
- data/app/serializers/meta_model/property_serializer.rb +0 -6
- data/lib/meta_model.rb +0 -4
- data/lib/meta_model/engine.rb +0 -23
- data/lib/meta_model/version.rb +0 -3
@@ -0,0 +1,25 @@
|
|
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 Neo4j
|
13
|
+
module MetaModel
|
14
|
+
class Engine < ::Rails::Engine
|
15
|
+
isolate_namespace MetaModel
|
16
|
+
|
17
|
+
initializer :assets do |config|
|
18
|
+
Rails.application.config.assets.precompile += %w( admin/models.js meta_model.js
|
19
|
+
meta_model.css )
|
20
|
+
|
21
|
+
Rails.application.config.assets.paths << "#{Rails.root}/vendor/assets/fonts"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4j-meta_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Underwood
|
@@ -131,41 +131,41 @@ files:
|
|
131
131
|
- app/assets/javascripts/templates/models/edit.emblem
|
132
132
|
- app/assets/javascripts/templates/models/hierarchy.emblem
|
133
133
|
- app/assets/stylesheets/meta_model.css.scss
|
134
|
-
- app/controllers/meta_model/application_controller.rb
|
135
|
-
- app/controllers/meta_model/meta/has_associations_controller.rb
|
136
|
-
- app/controllers/meta_model/meta/models_controller.rb
|
137
|
-
- app/controllers/meta_model/meta/properties_controller.rb
|
138
|
-
- app/controllers/meta_model/meta_controller.rb
|
139
|
-
- app/controllers/meta_model/models_controller.rb
|
140
|
-
- app/helpers/meta_model/application_helper.rb
|
141
|
-
- app/helpers/meta_model/model_helper.rb
|
142
|
-
- app/models/concerns/meta_model/model_base.rb
|
143
|
-
- app/models/meta_model/has_association.rb
|
144
|
-
- app/models/meta_model/meta_model_base.rb
|
145
|
-
- app/models/meta_model/model.rb
|
146
|
-
- app/models/meta_model/property.rb
|
147
|
-
- app/serializers/meta_model/has_association_serializer.rb
|
148
|
-
- app/serializers/meta_model/model_serializer.rb
|
149
|
-
- app/serializers/meta_model/property_serializer.rb
|
134
|
+
- app/controllers/neo4j/meta_model/application_controller.rb
|
135
|
+
- app/controllers/neo4j/meta_model/meta/has_associations_controller.rb
|
136
|
+
- app/controllers/neo4j/meta_model/meta/models_controller.rb
|
137
|
+
- app/controllers/neo4j/meta_model/meta/properties_controller.rb
|
138
|
+
- app/controllers/neo4j/meta_model/meta_controller.rb
|
139
|
+
- app/controllers/neo4j/meta_model/models_controller.rb
|
140
|
+
- app/helpers/neo4j/meta_model/application_helper.rb
|
141
|
+
- app/helpers/neo4j/meta_model/model_helper.rb
|
142
|
+
- app/models/concerns/neo4j/meta_model/model_base.rb
|
143
|
+
- app/models/neo4j/meta_model/has_association.rb
|
144
|
+
- app/models/neo4j/meta_model/meta_model_base.rb
|
145
|
+
- app/models/neo4j/meta_model/model.rb
|
146
|
+
- app/models/neo4j/meta_model/property.rb
|
147
|
+
- app/serializers/neo4j/meta_model/has_association_serializer.rb
|
148
|
+
- app/serializers/neo4j/meta_model/model_serializer.rb
|
149
|
+
- app/serializers/neo4j/meta_model/property_serializer.rb
|
150
150
|
- app/views/layouts/meta_model.html.slim
|
151
|
-
- app/views/meta_model/meta/associations/index.html.slim
|
152
|
-
- app/views/meta_model/meta/index.html.slim
|
153
|
-
- app/views/meta_model/meta/models/edit.html.slim
|
154
|
-
- app/views/meta_model/models/_form.html.slim
|
155
|
-
- app/views/meta_model/models/_has_many_association.html.slim
|
156
|
-
- app/views/meta_model/models/_record_details.html.slim
|
157
|
-
- app/views/meta_model/models/edit.html.slim
|
158
|
-
- app/views/meta_model/models/index.html.slim
|
159
|
-
- app/views/meta_model/models/meta_index.html.slim
|
160
|
-
- app/views/meta_model/models/new.html.slim
|
161
|
-
- app/views/meta_model/models/show.html.slim
|
151
|
+
- app/views/neo4j/meta_model/meta/associations/index.html.slim
|
152
|
+
- app/views/neo4j/meta_model/meta/index.html.slim
|
153
|
+
- app/views/neo4j/meta_model/meta/models/edit.html.slim
|
154
|
+
- app/views/neo4j/meta_model/models/_form.html.slim
|
155
|
+
- app/views/neo4j/meta_model/models/_has_many_association.html.slim
|
156
|
+
- app/views/neo4j/meta_model/models/_record_details.html.slim
|
157
|
+
- app/views/neo4j/meta_model/models/edit.html.slim
|
158
|
+
- app/views/neo4j/meta_model/models/index.html.slim
|
159
|
+
- app/views/neo4j/meta_model/models/meta_index.html.slim
|
160
|
+
- app/views/neo4j/meta_model/models/new.html.slim
|
161
|
+
- app/views/neo4j/meta_model/models/show.html.slim
|
162
162
|
- config/initializers/active_model_serializer.rb
|
163
163
|
- config/routes.rb
|
164
164
|
- lib/ext/hash.rb
|
165
|
-
- lib/meta_model.rb
|
166
|
-
- lib/meta_model/engine.rb
|
167
|
-
- lib/meta_model/version.rb
|
168
165
|
- lib/meta_models.rb
|
166
|
+
- lib/neo4j/meta_model.rb
|
167
|
+
- lib/neo4j/meta_model/engine.rb
|
168
|
+
- lib/neo4j/meta_model/version.rb
|
169
169
|
- lib/tasks/meta_model_tasks.rake
|
170
170
|
- test/dummy/README.rdoc
|
171
171
|
- test/dummy/Rakefile
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module MetaModel
|
2
|
-
module Meta
|
3
|
-
class HasAssociationsController < ApplicationController
|
4
|
-
before_action :get_has_association, only: [:edit, :show, :update, :destroy]
|
5
|
-
|
6
|
-
def index
|
7
|
-
render json: HasAssociation.all
|
8
|
-
end
|
9
|
-
|
10
|
-
def show
|
11
|
-
respond_to do |format|
|
12
|
-
format.json { render json: @has_association }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def create
|
17
|
-
has_association = HasAssociation.create(has_association_params)
|
18
|
-
|
19
|
-
create_models
|
20
|
-
|
21
|
-
render json: has_association
|
22
|
-
end
|
23
|
-
|
24
|
-
def destroy
|
25
|
-
@has_association.destroy
|
26
|
-
|
27
|
-
create_models
|
28
|
-
|
29
|
-
render json: nil
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def get_has_association
|
36
|
-
@has_association = HasAssociation.find(params[:id])
|
37
|
-
end
|
38
|
-
|
39
|
-
def has_association_params
|
40
|
-
params.require(:has_association).permit(:join_type, :name, :opposite_name, :relationship_type, :from_model_id, :to_model_id)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
module MetaModel
|
2
|
-
module Meta
|
3
|
-
class ModelsController < ApplicationController
|
4
|
-
before_action :get_model, only: [:edit, :show, :update, :destroy]
|
5
|
-
|
6
|
-
def index
|
7
|
-
respond_to do |format|
|
8
|
-
format.html { @hierarchy = Model.all.hierarchically }
|
9
|
-
format.json { render json: Model.all }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def hierarchy
|
14
|
-
respond_to do |format|
|
15
|
-
format.json { render json: Model.all.hierarchically }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def show
|
20
|
-
respond_to do |format|
|
21
|
-
format.json do
|
22
|
-
render json: @model
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def edit
|
28
|
-
@models = Model.all.order(:name)
|
29
|
-
end
|
30
|
-
|
31
|
-
def create
|
32
|
-
model = Model.create(model_params)
|
33
|
-
|
34
|
-
create_models
|
35
|
-
|
36
|
-
render json: model
|
37
|
-
end
|
38
|
-
|
39
|
-
def update
|
40
|
-
model_params.each do |key, value|
|
41
|
-
@model.send("#{key}=", value)
|
42
|
-
end
|
43
|
-
@model.save
|
44
|
-
|
45
|
-
create_models
|
46
|
-
|
47
|
-
render json: @model
|
48
|
-
end
|
49
|
-
|
50
|
-
def destroy
|
51
|
-
@model.destroy
|
52
|
-
|
53
|
-
create_models
|
54
|
-
|
55
|
-
render json: nil
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def get_model
|
61
|
-
@model = if model_param_class_name
|
62
|
-
Model.where(class_name: model_param_class_name).first
|
63
|
-
end || Model.find(params[:id])
|
64
|
-
end
|
65
|
-
|
66
|
-
def model_param_class_name
|
67
|
-
if params[:id]
|
68
|
-
@model_param_class_name ||= params[:id].classify
|
69
|
-
end
|
70
|
-
rescue NameError
|
71
|
-
end
|
72
|
-
|
73
|
-
def model_params
|
74
|
-
superclass_model = params[:model].delete(:superclass_model_id)
|
75
|
-
params.require(:model).permit(:class_name, :superclass_model).merge(superclass_model: superclass_model)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module MetaModel
|
2
|
-
module Meta
|
3
|
-
class PropertiesController < ApplicationController
|
4
|
-
before_action :get_property, only: [:edit, :show, :update, :destroy]
|
5
|
-
|
6
|
-
def destroy
|
7
|
-
@property.destroy
|
8
|
-
|
9
|
-
render json: nil
|
10
|
-
end
|
11
|
-
|
12
|
-
def create
|
13
|
-
property = Property.create(property_params)
|
14
|
-
|
15
|
-
render json: property
|
16
|
-
end
|
17
|
-
|
18
|
-
def update
|
19
|
-
@property.update_attributes(property_params)
|
20
|
-
|
21
|
-
render json: @property
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def get_property
|
27
|
-
@property = Property.find(params[:id])
|
28
|
-
end
|
29
|
-
|
30
|
-
def property_params
|
31
|
-
model = params[:property].delete(:model_id)
|
32
|
-
params.require(:property).permit(:name, :type).merge(model: model)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
module MetaModel
|
2
|
-
class ModelsController < MetaModel::ApplicationController
|
3
|
-
before_action :get_model
|
4
|
-
before_action :get_meta_model
|
5
|
-
before_action :get_record, only: [:show, :edit, :update]
|
6
|
-
|
7
|
-
layout 'layouts/meta_model'
|
8
|
-
def meta_index
|
9
|
-
@hierarchy = Model.order(:class_name).hierarchically
|
10
|
-
end
|
11
|
-
|
12
|
-
def index
|
13
|
-
@records = @model.all.to_a
|
14
|
-
respond_to do |format|
|
15
|
-
format.html
|
16
|
-
format.json { render json: @records, root: :records }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def show
|
21
|
-
end
|
22
|
-
|
23
|
-
def edit
|
24
|
-
end
|
25
|
-
|
26
|
-
def update
|
27
|
-
@record.update_attributes(params[:data])
|
28
|
-
|
29
|
-
redirect_to action: :show
|
30
|
-
end
|
31
|
-
|
32
|
-
def new
|
33
|
-
@record = @model.new
|
34
|
-
end
|
35
|
-
|
36
|
-
def create
|
37
|
-
record = @model.create(params[:data])
|
38
|
-
|
39
|
-
redirect_to action: :show, id: record.id
|
40
|
-
end
|
41
|
-
|
42
|
-
def destroy
|
43
|
-
@record.destroy
|
44
|
-
|
45
|
-
redirect_to action: :index, model: params[:model]
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def get_record
|
51
|
-
@record = @model.find(params[:id])
|
52
|
-
end
|
53
|
-
|
54
|
-
def get_meta_model
|
55
|
-
@meta_model = Model.where(class_name: model_param_class_name).first if model_param_class_name
|
56
|
-
end
|
57
|
-
|
58
|
-
def get_model
|
59
|
-
@model = "MetaModel::#{model_param_class_name}".constantize if model_param_class_name
|
60
|
-
end
|
61
|
-
|
62
|
-
def model_param_class_name
|
63
|
-
if params[:model]
|
64
|
-
@model_param_class_name ||= params[:model].classify
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module MetaModel
|
2
|
-
module ApplicationHelper
|
3
|
-
def action_and_controller_javascript_include_tag
|
4
|
-
capture do
|
5
|
-
concat javascript_include_tag controller_path if Rails.root.join("app/assets/javascripts/#{controller_path}.js.coffee").exist?
|
6
|
-
concat javascript_include_tag "#{controller_path}/#{action_name}" if Rails.root.join("app/assets/javascripts/#{controller_path}/#{action_name}.js.coffee").exist?
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module MetaModel
|
2
|
-
module ModelBase
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
LOADED_CLASSES = []
|
6
|
-
included do |base|
|
7
|
-
LOADED_CLASSES << self
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
def inherited(base)
|
12
|
-
LOADED_CLASSES << base
|
13
|
-
end
|
14
|
-
|
15
|
-
def meta_model_class
|
16
|
-
name.gsub(/^MetaModel::/, '')
|
17
|
-
end
|
18
|
-
|
19
|
-
def naming_column
|
20
|
-
# Probably want to allow the user to choose this
|
21
|
-
MetaModel::Model.where(class_name: meta_model_class).first.properties.detect {|p| p.type == 'String' }.name
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def naming_column_value
|
26
|
-
self.read_attribute(self.class.naming_column)
|
27
|
-
end
|
28
|
-
|
29
|
-
def meta_model_class
|
30
|
-
self.class.meta_model_class
|
31
|
-
end
|
32
|
-
|
33
|
-
def association_values
|
34
|
-
self.class.associations.each_with_object({}) do |(key, _), result|
|
35
|
-
result[key] = self.send(key)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def _description
|
40
|
-
self.try(:name) || self.try(:name) || self.try(:description) || self.id
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|