activegraph 10.0.0.pre.beta.5 → 10.0.0.pre.beta.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/activegraph.gemspec +1 -1
  3. data/lib/active_graph/core/querable.rb +2 -6
  4. data/lib/active_graph/core/query.rb +2 -2
  5. data/lib/active_graph/core/query_find_in_batches.rb +4 -7
  6. data/lib/active_graph/core/record.rb +51 -0
  7. data/lib/active_graph/core/result.rb +17 -20
  8. data/lib/active_graph/core/schema.rb +12 -8
  9. data/lib/active_graph/core.rb +3 -1
  10. data/lib/active_graph/migrations/schema.rb +1 -1
  11. data/lib/active_graph/node/persistence.rb +2 -2
  12. data/lib/active_graph/node/query/query_proxy_eager_loading.rb +1 -1
  13. data/lib/active_graph/node/query/query_proxy_find_in_batches.rb +2 -2
  14. data/lib/active_graph/node/query/query_proxy_methods.rb +2 -1
  15. data/lib/active_graph/node/query/query_proxy_methods_of_mass_updating.rb +1 -1
  16. data/lib/active_graph/node/query_methods.rb +3 -3
  17. data/lib/active_graph/relationship/persistence/query_factory.rb +3 -3
  18. data/lib/active_graph/relationship/query.rb +1 -1
  19. data/lib/active_graph/version.rb +1 -1
  20. data/lib/active_graph.rb +1 -1
  21. data/lib/rails/generators/{neo4j → active_graph}/migration/migration_generator.rb +2 -0
  22. data/lib/rails/generators/{neo4j → active_graph}/migration/templates/migration.erb +0 -0
  23. data/lib/rails/generators/{neo4j → active_graph}/model/model_generator.rb +2 -1
  24. data/lib/rails/generators/{neo4j → active_graph}/model/templates/migration.erb +0 -0
  25. data/lib/rails/generators/{neo4j → active_graph}/model/templates/model.erb +0 -0
  26. data/lib/rails/generators/{neo4j → active_graph}/upgrade_v8/templates/migration.erb +0 -0
  27. data/lib/rails/generators/{neo4j → active_graph}/upgrade_v8/upgrade_v8_generator.rb +2 -0
  28. data/lib/rails/generators/{neo4j_generator.rb → active_graph_generator.rb} +3 -1
  29. metadata +13 -13
  30. data/lib/active_graph/core/responses.rb +0 -50
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f768ee99674bbc10fb6c1094921b8f6f7840cfdd6c2d2ae442e4cc33d243690a
4
- data.tar.gz: 46d381583be9bd03f45d8b6f684d2bc3ae0e394ebcbd2685d57cda834f354e24
3
+ metadata.gz: f2d132e9650a26653214b08a0eb1011f3055423f8b06595ccfa6916d0bafe535
4
+ data.tar.gz: 39d0462710f928dbe895ec75c1e6b82f137cb73681c2f41edf069f8da56321e3
5
5
  SHA512:
6
- metadata.gz: fbd8b19f5894b9b5b528887aff9616f62d08818c90a03e1b9144850c1c832061f6af598a4d5ebf8a1d9e9751bfb6a1ba7bfa730df83a43070e0f95081a799347
7
- data.tar.gz: 4c02f0e0ab88bffdafb794a892aacd46351118bb7dbe179a1fab56dc2febe9a6bee08d2d0c6850580c039b493e5eb76cc4a77b57a272c09d2f4a286f134d237b
6
+ metadata.gz: 83b22026f597bd92afdf7e27319f3d4c5e40dcb54d5b121f4cbab3d32e669e29199e90cc9f662500698c9abf336fe7905de46eb57d1ec368fff8361531afc1eb
7
+ data.tar.gz: ac6c4bc78512ddf185e0245c28cb78b8f09cd80aeb10d583ae591a3d542ff5a269b918aad9895805ba73267bece5330b0417166fbe7298a29dfa5f0e65f1936f
data/activegraph.gemspec CHANGED
@@ -38,7 +38,7 @@ DESCRIPTION
38
38
  s.add_development_dependency('guard-rspec')
39
39
  s.add_development_dependency('guard-rubocop')
40
40
  s.add_development_dependency('neo4j-rake_tasks', '>= 0.3.0')
41
- s.add_development_dependency("neo4j-#{ENV['driver'] == 'java' ? 'java' : 'ruby'}-driver", '>= 0.3.5')
41
+ s.add_development_dependency("neo4j-#{ENV['driver'] == 'java' ? 'java' : 'ruby'}-driver", '>= 0.4.0')
42
42
  s.add_development_dependency('os')
43
43
  s.add_development_dependency('pry')
44
44
  s.add_development_dependency('railties', '>= 4.0')
@@ -1,14 +1,13 @@
1
1
  require 'active_graph/core/instrumentable'
2
2
  require 'active_graph/transaction'
3
3
  require 'active_graph/core/query_builder'
4
- require 'active_graph/core/responses'
4
+ require 'active_graph/core/record'
5
5
 
6
6
  module ActiveGraph
7
7
  module Core
8
8
  module Querable
9
9
  extend ActiveSupport::Concern
10
10
  include Instrumentable
11
- include Responses
12
11
 
13
12
  class_methods do
14
13
  def query(*args)
@@ -43,14 +42,11 @@ module ActiveGraph
43
42
  setup_queries!(queries, skip_instrumentation: options[:skip_instrumentation])
44
43
 
45
44
  ActiveSupport::Notifications.instrument('neo4j.core.bolt.request') do
46
- self.wrap_level = options[:wrap_level]
47
45
  transaction do |tx|
48
46
  queries.map do |query|
49
- result_from_data(tx.run(query.cypher, query.parameters))
47
+ tx.run(query.cypher, query.parameters).tap { |result| result.wrap = options[:wrap] != false }
50
48
  end
51
49
  end
52
- rescue Neo4j::Driver::Exceptions::Neo4jException => e
53
- raise ActiveGraph::Core::CypherError.new_from(e.code, e.message) # , e.stack_track.to_a
54
50
  end
55
51
  end
56
52
  end
@@ -235,7 +235,7 @@ module ActiveGraph
235
235
  def response
236
236
  return @response if @response
237
237
 
238
- @response = ActiveGraph::Base.query(self, wrap_level: (:core_entity if unwrapped?))
238
+ @response = ActiveGraph::Base.query(self, wrap: !unwrapped?)
239
239
  end
240
240
 
241
241
  def raise_if_cypher_error!(response)
@@ -294,7 +294,7 @@ module ActiveGraph
294
294
  fail ArgumentError, 'No columns specified for Query#pluck' if columns.size.zero?
295
295
 
296
296
  query = return_query(columns)
297
- columns = query.response.columns
297
+ columns = query.response.keys
298
298
 
299
299
  if columns.size == 1
300
300
  column = columns[0]
@@ -36,13 +36,10 @@ module ActiveGraph
36
36
  end
37
37
 
38
38
  def primary_key_offset(last_record, node_var, prop_var)
39
- last_record.send(node_var).send(prop_var)
40
- rescue NoMethodError
41
- begin
42
- last_record.send(node_var).properties[prop_var.to_sym]
43
- rescue NoMethodError
44
- last_record.send("#{node_var}.#{prop_var}") # In case we're explicitly returning it
45
- end
39
+ node = last_record[node_var]
40
+ return node.send(prop_var) if node&.respond_to?(prop_var)
41
+ return node.properties[prop_var.to_sym] if node&.respond_to?(:properties)
42
+ last_record["#{node_var}.#{prop_var}"] # In case we're explicitly returning it
46
43
  end
47
44
  end
48
45
  end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_graph/core/result'
4
+ require 'active_support/core_ext/module/attribute_accessors'
5
+
6
+ module ActiveGraph
7
+ module Core
8
+ module Record
9
+ attr_writer :wrap
10
+
11
+ def values
12
+ wrap(super)
13
+ end
14
+
15
+ def first
16
+ wrap(super)
17
+ end
18
+
19
+ def [](key)
20
+ wrap(super)
21
+ end
22
+
23
+ def to_h
24
+ wrap(super)
25
+ end
26
+
27
+ private
28
+
29
+ def wrap(value)
30
+ return value unless wrap?
31
+
32
+ case value
33
+ when Neo4j::Driver::Types::Entity
34
+ value.wrap
35
+ when Neo4j::Driver::Types::Path
36
+ value
37
+ when Hash
38
+ value.transform_values(&method(:wrap))
39
+ when Enumerable
40
+ value.map!(&method(:wrap))
41
+ else
42
+ value
43
+ end
44
+ end
45
+
46
+ def wrap?
47
+ @wrap
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,31 +1,28 @@
1
1
  module ActiveGraph
2
2
  module Core
3
- class Result
4
- attr_reader :columns, :rows
3
+ module Result
4
+ attr_writer :wrap
5
5
 
6
- def initialize(columns, rows)
7
- @columns = columns.map(&:to_sym)
8
- @rows = rows
9
- @struct_class = Struct.new(:index, *@columns)
6
+ def wrap?
7
+ @wrap
10
8
  end
11
9
 
12
- include Enumerable
13
-
14
- def each
15
- structs.each do |struct|
16
- yield struct
17
- end
10
+ def each(&block)
11
+ wrap? ? wrapping_each(&block) : super
18
12
  end
19
13
 
20
- def structs
21
- @structs ||= rows.each_with_index.map do |row, index|
22
- @struct_class.new(index, *row)
23
- end
24
- end
14
+ private
25
15
 
26
- def hashes
27
- @hashes ||= rows.map do |row|
28
- Hash[@columns.zip(row)]
16
+ def wrapping_each(&block)
17
+ if @records
18
+ @records.each(&block)
19
+ else
20
+ @records = []
21
+ method(:each).super_method.call do |record|
22
+ record.wrap = wrap?
23
+ @records << record
24
+ block_given? ? yield(record) : record
25
+ end
29
26
  end
30
27
  end
31
28
  end
@@ -5,14 +5,14 @@ module ActiveGraph
5
5
  result = query('CALL dbms.components()', {}, skip_instrumentation: true)
6
6
 
7
7
  # BTW: community / enterprise could be retrieved via `result.first.edition`
8
- result.first.versions[0]
8
+ result.first[:versions][0]
9
9
  end
10
10
 
11
11
  def indexes
12
12
  result = query('CALL db.indexes()', {}, skip_instrumentation: true)
13
13
 
14
14
  result.map do |row|
15
- { type: row.type.to_sym, label: label(result, row), properties: properties(row), state: row.state.to_sym }
15
+ { type: row[:type].to_sym, label: label(result, row), properties: properties(row), state: row[:state].to_sym }
16
16
  end
17
17
  end
18
18
 
@@ -27,29 +27,33 @@ module ActiveGraph
27
27
  private
28
28
 
29
29
  def v4_filter(row)
30
- row.uniqueness == 'UNIQUE'
30
+ row[:uniqueness] == 'UNIQUE'
31
31
  end
32
32
 
33
33
  def v3_filter(row)
34
- row.type == 'node_unique_property'
34
+ row[:type] == 'node_unique_property'
35
35
  end
36
36
 
37
37
  def label(result, row)
38
- (v34?(result) ? row.label : (v4?(result) ? row.labelsOrTypes : row.tokenNames).first).to_sym
38
+ if v34?(result)
39
+ row[:label]
40
+ else
41
+ (v4?(result) ? row[:labelsOrTypes] : row[:tokenNames]).first
42
+ end.to_sym
39
43
  end
40
44
 
41
45
  def v4?(result)
42
46
  return @v4 unless @v4.nil?
43
- @v4 = result.columns.include?(:labelsOrTypes)
47
+ @v4 = result.keys.include?(:labelsOrTypes)
44
48
  end
45
49
 
46
50
  def v34?(result)
47
51
  return @v34 unless @v34.nil?
48
- @v34 = result.columns.include?(:label)
52
+ @v34 = result.keys.include?(:label)
49
53
  end
50
54
 
51
55
  def properties(row)
52
- row.properties.map(&:to_sym)
56
+ row[:properties].map(&:to_sym)
53
57
  end
54
58
  end
55
59
  end
@@ -1,7 +1,7 @@
1
1
  require 'active_graph/transaction'
2
2
  require 'active_graph/core/instrumentable'
3
3
  require 'active_graph/core/query'
4
- require 'active_graph/core/responses'
4
+ require 'active_graph/core/record'
5
5
 
6
6
  require 'neo4j_ruby_driver'
7
7
  require 'active_graph/core/wrappable'
@@ -11,3 +11,5 @@ require 'active_graph/core/relationship'
11
11
  Neo4j::Driver::Types::Entity.include ActiveGraph::Core::Wrappable
12
12
  Neo4j::Driver::Types::Node.prepend ActiveGraph::Core::Node
13
13
  Neo4j::Driver::Types::Relationship.include ActiveGraph::Core::Relationship
14
+ Neo4j::Driver::StatementResult.prepend ActiveGraph::Core::Result
15
+ Neo4j::Driver::Record.prepend ActiveGraph::Core::Record
@@ -24,7 +24,7 @@ module ActiveGraph
24
24
 
25
25
  def fetch_index_descriptions
26
26
  result = ActiveGraph::Base.query('CALL db.indexes()')
27
- if result.columns.include?(:description)
27
+ if result.keys.include?(:description)
28
28
  v3_indexes(result)
29
29
  else
30
30
  v4_indexes(result)
@@ -67,7 +67,7 @@ module ActiveGraph::Node
67
67
  # @return [ActiveGraph::Node] A CypherNode or EmbeddedNode
68
68
  def _create_node(node_props, labels = labels_for_create)
69
69
  query = "CREATE (n:`#{Array(labels).join('`:`')}`) SET n = $props RETURN n"
70
- neo4j_query(query, {props: node_props}, wrap_level: :core_entity).to_a[0].n
70
+ neo4j_query(query, {props: node_props}, wrap: false).to_a[0][:n]
71
71
  end
72
72
 
73
73
  # As the name suggests, this inserts the primary key (id property) into the properties hash.
@@ -157,7 +157,7 @@ module ActiveGraph::Node
157
157
  def load_entity(id)
158
158
  query = query_base_for(id, :n).return(:n)
159
159
  result = neo4j_query(query).first
160
- result && result.n
160
+ result && result[:n]
161
161
  end
162
162
 
163
163
  def query_base_for(neo_id, var = :n)
@@ -16,7 +16,7 @@ module ActiveGraph
16
16
  @_cache = IdentityMap.new
17
17
  build_query
18
18
  .map do |record, eager_data|
19
- cache_and_init(record, with_associations_tree)
19
+ record = cache_and_init(record, with_associations_tree)
20
20
  eager_data.zip(with_associations_tree.paths.map(&:last)).each do |eager_records, element|
21
21
  eager_records.first.zip(eager_records.last).each do |eager_record|
22
22
  add_to_cache(*eager_record, element)
@@ -4,13 +4,13 @@ module ActiveGraph
4
4
  module QueryProxyFindInBatches
5
5
  def find_in_batches(options = {})
6
6
  query.return(identity).find_in_batches(identity, @model.primary_key, options) do |batch|
7
- yield batch.map(&identity)
7
+ yield batch.map { |record| record[identity] }
8
8
  end
9
9
  end
10
10
 
11
11
  def find_each(options = {})
12
12
  query.return(identity).find_each(identity, @model.primary_key, options) do |result|
13
- yield result.send(identity)
13
+ yield result[identity]
14
14
  end
15
15
  end
16
16
  end
@@ -93,7 +93,8 @@ module ActiveGraph
93
93
  "#{var}.#{association_id_key} = $other_node_id"
94
94
  end
95
95
  node_id = other.respond_to?(:neo_id) ? other.neo_id : other
96
- self.where(where_filter).params(other_node_id: node_id).query.reorder.return("count(#{var}) as count").first.count > 0
96
+ self.where(where_filter).params(other_node_id: node_id).query.reorder.return("count(#{var}) as count")
97
+ .first[:count].positive?
97
98
  end
98
99
  end
99
100
 
@@ -27,7 +27,7 @@ module ActiveGraph
27
27
  query_with_target(identifier) do |target|
28
28
  begin
29
29
  self.query.with(target).optional_match("(#{target})-[#{target}_rel]-()").delete("#{target}, #{target}_rel").exec
30
- rescue ActiveGraph::Core::CypherError # <=- Seems hacky
30
+ rescue Neo4j::Driver::Exceptions::ClientException # <=- Seems hacky
31
31
  self.query.delete(target).exec
32
32
  end
33
33
  clear_source_object_cache
@@ -25,7 +25,7 @@ module ActiveGraph
25
25
  def count(distinct = nil)
26
26
  fail(ActiveGraph::InvalidParameterError, ':count accepts the `:distinct` symbol or nil as a parameter') unless distinct.nil? || distinct == :distinct
27
27
  q = distinct.nil? ? 'n' : 'DISTINCT n'
28
- self.query_as(:n).return("count(#{q}) AS count").first.count
28
+ self.query_as(:n).return("count(#{q}) AS count").first[:count]
29
29
  end
30
30
 
31
31
  alias size count
@@ -39,13 +39,13 @@ module ActiveGraph
39
39
 
40
40
  def find_in_batches(options = {})
41
41
  self.query_as(:n).return(:n).find_in_batches(:n, primary_key, options) do |batch|
42
- yield batch.map(&:n)
42
+ yield batch.map { |record| record[:n] }
43
43
  end
44
44
  end
45
45
 
46
46
  def find_each(options = {})
47
47
  self.query_as(:n).return(:n).find_each(:n, primary_key, options) do |batch|
48
- yield batch.n
48
+ yield batch[:n]
49
49
  end
50
50
  end
51
51
 
@@ -22,7 +22,7 @@ module ActiveGraph::Relationship::Persistence
22
22
  node_before_callbacks! do
23
23
  res = query_factory(rel, rel_id, iterative_query).query.unwrapped.return(*unpersisted_return_ids).first
24
24
  node_symbols.each { |n| wrap!(send(n), res, n) }
25
- @unwrapped_rel = res.send(rel_id)
25
+ @unwrapped_rel = res[rel_id]
26
26
  end
27
27
  end
28
28
 
@@ -83,8 +83,8 @@ module ActiveGraph::Relationship::Persistence
83
83
  # in, making the object reflect as "persisted".
84
84
  # @param [Symbol] key :from_node or :to_node, the object to request from the response.
85
85
  def wrap!(node, res, key)
86
- return if node.persisted? || !res.respond_to?(key)
87
- unwrapped = res.send(key)
86
+ return if node.persisted? || !res.keys.include?(key)
87
+ unwrapped = res[key]
88
88
  node.init_on_load(unwrapped, unwrapped.props)
89
89
  end
90
90
 
@@ -17,7 +17,7 @@ module ActiveGraph::Relationship
17
17
  query = ActiveGraph::Base.new_query
18
18
  result = query.match('()-[r]-()').where('ID(r)' => key.to_i).limit(1).return(:r).first
19
19
  fail RecordNotFound.new("Couldn't find #{name} with 'id'=#{key.inspect}", name, key) if result.blank?
20
- result.r
20
+ result[:r]
21
21
  end
22
22
 
23
23
  # Performs a very basic match on the relationship.
@@ -1,3 +1,3 @@
1
1
  module ActiveGraph
2
- VERSION = '10.0.0-beta.5'
2
+ VERSION = '10.0.0-beta.6'
3
3
  end
data/lib/active_graph.rb CHANGED
@@ -117,7 +117,7 @@ load 'active_graph/tasks/migration.rake'
117
117
  require 'active_graph/node/orm_adapter'
118
118
  if defined?(Rails)
119
119
  require 'rails/generators'
120
- require 'rails/generators/neo4j_generator'
120
+ require 'rails/generators/active_graph_generator'
121
121
  end
122
122
 
123
123
  Neo4j::Driver::Transaction.prepend ActiveGraph::Transaction
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'active_graph.rb')
2
4
 
3
5
  module ActiveGraph
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'active_graph.rb')
2
4
 
3
5
  class ActiveGraph::Generators::ModelGenerator < Rails::Generators::NamedBase #:nodoc:
@@ -62,7 +64,6 @@ class ActiveGraph::Generators::ModelGenerator < Rails::Generators::NamedBase #:n
62
64
  options[:indices]
63
65
  end
64
66
 
65
-
66
67
  def index_fragment(property)
67
68
  return if !options[:indices] || !options[:indices].include?(property)
68
69
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'active_graph.rb')
2
4
 
3
5
  module ActiveGraph
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/generators/named_base'
2
4
  require 'rails/generators/active_model'
3
5
 
@@ -59,7 +61,7 @@ module ActiveGraph::Generators::SourcePathHelper
59
61
  module ClassMethods
60
62
  def source_root
61
63
  @_neo4j_source_root ||= File.expand_path(File.join(File.dirname(__FILE__),
62
- 'neo4j', generator_name, 'templates'))
64
+ 'active_graph', generator_name, 'templates'))
63
65
  end
64
66
  end
65
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activegraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0.pre.beta.5
4
+ version: 10.0.0.pre.beta.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge, Brian Underwood, Chris Grigg, Heinrich Klobuczek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-05 00:00:00.000000000 Z
11
+ date: 2020-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: 0.3.5
131
+ version: 0.4.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: 0.3.5
138
+ version: 0.4.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: os
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -272,8 +272,8 @@ files:
272
272
  - lib/active_graph/core/query_clauses.rb
273
273
  - lib/active_graph/core/query_ext.rb
274
274
  - lib/active_graph/core/query_find_in_batches.rb
275
+ - lib/active_graph/core/record.rb
275
276
  - lib/active_graph/core/relationship.rb
276
- - lib/active_graph/core/responses.rb
277
277
  - lib/active_graph/core/result.rb
278
278
  - lib/active_graph/core/schema.rb
279
279
  - lib/active_graph/core/schema_errors.rb
@@ -378,14 +378,14 @@ files:
378
378
  - lib/active_graph/undeclared_properties.rb
379
379
  - lib/active_graph/version.rb
380
380
  - lib/active_graph/wrapper.rb
381
- - lib/rails/generators/neo4j/migration/migration_generator.rb
382
- - lib/rails/generators/neo4j/migration/templates/migration.erb
383
- - lib/rails/generators/neo4j/model/model_generator.rb
384
- - lib/rails/generators/neo4j/model/templates/migration.erb
385
- - lib/rails/generators/neo4j/model/templates/model.erb
386
- - lib/rails/generators/neo4j/upgrade_v8/templates/migration.erb
387
- - lib/rails/generators/neo4j/upgrade_v8/upgrade_v8_generator.rb
388
- - lib/rails/generators/neo4j_generator.rb
381
+ - lib/rails/generators/active_graph/migration/migration_generator.rb
382
+ - lib/rails/generators/active_graph/migration/templates/migration.erb
383
+ - lib/rails/generators/active_graph/model/model_generator.rb
384
+ - lib/rails/generators/active_graph/model/templates/migration.erb
385
+ - lib/rails/generators/active_graph/model/templates/model.erb
386
+ - lib/rails/generators/active_graph/upgrade_v8/templates/migration.erb
387
+ - lib/rails/generators/active_graph/upgrade_v8/upgrade_v8_generator.rb
388
+ - lib/rails/generators/active_graph_generator.rb
389
389
  homepage: https://github.com/neo4jrb/activegraph/
390
390
  licenses:
391
391
  - MIT
@@ -1,50 +0,0 @@
1
- require 'active_graph/core/result'
2
- require 'active_support/core_ext/module/attribute_accessors'
3
-
4
- module ActiveGraph
5
- module Core
6
- module Responses
7
- extend ActiveSupport::Concern
8
-
9
- included do
10
- mattr_accessor :wrap_level
11
- end
12
-
13
- class_methods do
14
- def result_from_data(entities_data)
15
- rows = entities_data.map do |entity_data|
16
- wrap(entity_data.values)
17
- end
18
-
19
- ActiveGraph::Core::Result.new(entities_data.keys, rows)
20
- end
21
-
22
- private
23
-
24
- def wrap(value)
25
- case value
26
- when Neo4j::Driver::Types::Entity
27
- wrap_by_level(value)
28
- when Neo4j::Driver::Types::Path
29
- value
30
- when Hash
31
- value.map { |key, val| [key, wrap(val)] }.to_h
32
- when Enumerable
33
- value.map(&method(:wrap))
34
- else
35
- value
36
- end
37
- end
38
-
39
- def wrap_by_level(entity)
40
- case wrap_level
41
- when :core_entity
42
- entity
43
- else
44
- entity.wrap
45
- end
46
- end
47
- end
48
- end
49
- end
50
- end