-
Notifications
You must be signed in to change notification settings - Fork 30
Session execute_read/write implementation #251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
f5e2be8
db04fb7
f62734f
0908098
d3c3b91
3a02b3d
792d216
df0e161
47b6b1e
d559d46
fbbd7a6
f6bb76f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,20 @@ module InternalSession | |
# work around jruby issue https://github.com/jruby/jruby/issues/5603 | ||
Struct.new('Wrapper', :object) | ||
|
||
%i[read write].each do |prefix| | ||
define_method("#{prefix}_transaction") do |**config, &block| | ||
check do | ||
super(->(tx) { Struct::Wrapper.new(reverse_check { block.call(tx) }) }, to_java_config(Neo4j::Driver::TransactionConfig, **config)).object | ||
# implementation of read_transaction, write_transaction, execute_read, execute_write | ||
%i[read write].each do |mode| | ||
["#{mode}_transaction", "execute_#{mode}"].each do |method_name| | ||
define_method(method_name) do |**config, &block| | ||
if method_name.include? 'transaction' | ||
Neo4j::Driver::Internal::Deprecator.log_warning(method_name, "execute_#{mode}".to_sym, '6.0') | ||
end | ||
|
||
check do | ||
super( | ||
->(tx) { Struct::Wrapper.new(reverse_check { block.call(tx) }) }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check if Struct::Wrapper is still required. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay, will check |
||
to_java_config(Neo4j::Driver::TransactionConfig, **config) | ||
).object | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's increase our max line length to 160. That's what we have on all our projects. |
||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would extract this to a separate private method. So the above logic can be simplified. |
||
end | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Neo4j | ||
module Driver | ||
module Internal | ||
module Deprecator | ||
def self.log_warning(old_method, new_method, version) | ||
@deprecator ||= ActiveSupport::Deprecation.new(version, 'neo4j-ruby-driver') | ||
@deprecator.deprecation_warning(old_method, new_method) | ||
end | ||
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of backwards and sort of duplication.
I think in this case it would be better to have 2 separate method definitions. One with deprecation and another without.