neo4j 7.1.4 → 7.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59a1f4ff6343398b192ac132595f0165fc65fec2
4
- data.tar.gz: e08ab0b4e2cf7716cf7b0ed085082a052360de77
3
+ metadata.gz: fa5400aef5ceed374df507212001259434a2550c
4
+ data.tar.gz: eb182d51d5f9107155dcc3cc7db72018b0ca16ca
5
5
  SHA512:
6
- metadata.gz: bd2af749c6b804e50ab8ca138124a570802f7eafbb75583a3487e3748af238d86c0bd3517fbe424aa99ed83b2e635e190bcfb90b93917e59c2b4ba45dec4fe12
7
- data.tar.gz: 0e75718feea9d08f69322c69c3989c8b0d367f423910f8ff8b701386cb146fbada6a00ce9da80f79fee11cee484b8887e90132c83834edbd9cdd0c5c477a425e
6
+ metadata.gz: d12724bd745a9d23b43a63f90a6bcd18114727035229cea23cf744db4ea0482832e4c44696246224f34b93ea3d3d091afa49bf8096b3a80ec695a92d68cb42c3
7
+ data.tar.gz: 609c35501f8b8a2ac5588820867d3c972f1ca1ce5dbe73456a3ff4f2de62e1f6a943eefcd2eb5098053bbc474dbf65baa63d0b6639f947f533f685e1a58accde
@@ -3,11 +3,11 @@ All notable changes to this project will be documented in this file.
3
3
  This file should follow the standards specified on [http://keepachangelog.com/]
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
- ## [7.1.4] - 09-20-2016
6
+ ## [7.2.0] - 08-23-2016
7
7
 
8
- ### Fixed
8
+ ### Added
9
9
 
10
- - `where` clause with question mark parameter and array values only using the first element (see #1247 #1290)
10
+ - Backporting #1245 to 7.x versions. It implements the [`ForbiddenAttributesProtection` API](http://edgeapi.rubyonrails.org/classes/ActionController/StrongParameters.html) from ActiveRecord.
11
11
 
12
12
  ## [7.1.3] - 08-18-2016
13
13
 
@@ -34,12 +34,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
34
34
  - Gemspec dependency requirements were modified where ActiveModel, ActiveSupport, and Railties are concerned. The gem now requires >= 4.0, < 5.1.
35
35
  - `ActiveModel::Serializers::Xml` is only included if supported if available.
36
36
 
37
- ## [7.0.16] - 09-20-2016
38
-
39
- ### Fixed
40
-
41
- - `where` clause with question mark parameter and array values only using the first element (see #1247 #1290)
42
-
43
37
  ## [7.0.15] - 08-18-2016
44
38
 
45
39
  ### Changed
@@ -40,6 +40,7 @@ require 'neo4j/shared/typecaster'
40
40
  require 'neo4j/shared/initialize'
41
41
  require 'neo4j/shared/query_factory'
42
42
  require 'neo4j/shared/cypher'
43
+ require 'neo4j/shared/permitted_attributes'
43
44
  require 'neo4j/shared'
44
45
 
45
46
  require 'neo4j/active_rel/callbacks'
@@ -44,10 +44,11 @@ module Neo4j
44
44
  include Neo4j::ActiveNode::Scope
45
45
  include Neo4j::ActiveNode::Dependent
46
46
  include Neo4j::ActiveNode::Enum
47
+ include Neo4j::Shared::PermittedAttributes
47
48
 
48
49
  def initialize(args = nil)
49
- symbol_args = args.is_a?(Hash) ? args.symbolize_keys : args
50
- super(symbol_args)
50
+ args = sanitize_input_parameters(args)
51
+ super(args)
51
52
  end
52
53
 
53
54
  def neo4j_obj
@@ -12,11 +12,7 @@ module Neo4j
12
12
  end
13
13
 
14
14
  def args(var, rel_var)
15
- if @arg.respond_to?(:call)
16
- @arg.call(var, rel_var)
17
- else
18
- [@arg] + @args
19
- end
15
+ @arg.respond_to?(:call) ? @arg.call(var, rel_var) : [@arg, @args].flatten
20
16
  end
21
17
 
22
18
  class << self
@@ -18,13 +18,14 @@ module Neo4j
18
18
  include Neo4j::ActiveRel::Query
19
19
  include Neo4j::ActiveRel::Types
20
20
  include Neo4j::Shared::Enum
21
+ include Neo4j::Shared::PermittedAttributes
21
22
 
22
23
  class FrozenRelError < Neo4j::Error; end
23
24
 
24
25
  def initialize(from_node = nil, to_node = nil, args = nil)
25
26
  load_nodes(node_or_nil(from_node), node_or_nil(to_node))
26
27
  resolved_args = hash_or_nil(from_node, args)
27
- symbol_args = resolved_args.is_a?(Hash) ? resolved_args.symbolize_keys : resolved_args
28
+ symbol_args = sanitize_input_parameters(resolved_args)
28
29
  super(symbol_args)
29
30
  end
30
31
 
@@ -60,26 +61,7 @@ module Neo4j
60
61
  end
61
62
 
62
63
  def hash_or_nil(node_or_hash, hash_or_nil)
63
- node_or_hash.is_a?(Hash) ? node_or_hash : hash_or_nil
64
- end
65
-
66
- module ClassMethods
67
- [:create, :create!].each do |meth|
68
- define_method(meth) do |from_node_or_args = nil, to_node = nil, args = nil|
69
- return super(from_node_or_args) if from_node_or_args.is_a?(Hash)
70
- args_hash = args || {}
71
- args_with_node!(:from_node, from_node_or_args, args_hash)
72
- args_with_node!(:to_node, to_node, args_hash)
73
- super(args_hash)
74
- end
75
- end
76
-
77
- private
78
-
79
- def args_with_node!(key, node, args)
80
- args[key] = node if node.is_a?(Neo4j::ActiveNode)
81
- args
82
- end
64
+ hash_or_parameter?(node_or_hash) ? node_or_hash : hash_or_nil
83
65
  end
84
66
  end
85
67
  end
@@ -55,26 +55,13 @@ module Neo4j::ActiveRel
55
55
  module ClassMethods
56
56
  # Creates a new relationship between objects
57
57
  # @param [Hash] props the properties the new relationship should have
58
- def create(props = {})
59
- relationship_props = extract_association_attributes!(props) || {}
60
- new(props).tap do |obj|
61
- relationship_props.each do |prop, value|
62
- obj.send("#{prop}=", value)
63
- end
64
- obj.save
65
- end
58
+ def create(*args)
59
+ new(*args).tap(&:save)
66
60
  end
67
61
 
68
62
  # Same as #create, but raises an error if there is a problem during save.
69
63
  def create!(*args)
70
- props = args[0] || {}
71
- relationship_props = extract_association_attributes!(props) || {}
72
- new(props).tap do |obj|
73
- relationship_props.each do |prop, value|
74
- obj.send("#{prop}=", value)
75
- end
76
- obj.save!
77
- end
64
+ new(*args).tap(&:save!)
78
65
  end
79
66
 
80
67
  def create_method
@@ -0,0 +1,28 @@
1
+ module Neo4j::Shared
2
+ module PermittedAttributes
3
+ extend ActiveSupport::Concern
4
+ include ActiveModel::ForbiddenAttributesProtection
5
+
6
+ def process_attributes(attributes)
7
+ attributes = sanitize_input_parameters(attributes)
8
+ super(attributes)
9
+ end
10
+
11
+ def attributes=(attributes)
12
+ attributes = sanitize_input_parameters(attributes)
13
+ super(attributes)
14
+ end
15
+
16
+ protected
17
+
18
+ # Check if an argument is a string or an ActionController::Parameters
19
+ def hash_or_parameter?(args)
20
+ args.is_a?(Hash) || args.respond_to?(:to_unsafe_h)
21
+ end
22
+
23
+ def sanitize_input_parameters(attributes)
24
+ attributes = sanitize_for_mass_assignment(attributes)
25
+ attributes.respond_to?(:symbolize_keys) ? attributes.symbolize_keys : attributes
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module Neo4j
2
- VERSION = '7.1.4'
2
+ VERSION = '7.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.4
4
+ version: 7.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge, Brian Underwood, Chris Grigg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-20 00:00:00.000000000 Z
11
+ date: 2016-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: orm_adapter
@@ -232,7 +232,6 @@ files:
232
232
  - Gemfile
233
233
  - README.md
234
234
  - bin/neo4j-jars
235
- - bin/rake
236
235
  - config/locales/en.yml
237
236
  - config/neo4j/add_classnames.yml
238
237
  - config/neo4j/config.yml
@@ -304,6 +303,7 @@ files:
304
303
  - lib/neo4j/shared/initialize.rb
305
304
  - lib/neo4j/shared/marshal.rb
306
305
  - lib/neo4j/shared/mass_assignment.rb
306
+ - lib/neo4j/shared/permitted_attributes.rb
307
307
  - lib/neo4j/shared/persistence.rb
308
308
  - lib/neo4j/shared/property.rb
309
309
  - lib/neo4j/shared/query_factory.rb
data/bin/rake DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
- #
4
- # This file was generated by Bundler.
5
- #
6
- # The application 'rake' is installed as part of a gem, and
7
- # this file is here to facilitate running it.
8
- #
9
-
10
- require 'pathname'
11
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
12
- Pathname.new(__FILE__).realpath)
13
-
14
- require 'rubygems'
15
- require 'bundler/setup'
16
-
17
- load Gem.bin_path('rake', 'rake')