Skip to content

Commit d05f819

Browse files
committed
yay
1 parent 26438b5 commit d05f819

5 files changed

Lines changed: 4385 additions & 4935 deletions

File tree

‎v4-cokapi/backends/ruby/pg_logger.rb‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
# TODO
1313
#
1414
# - display the 'binding' within a proc/lambda object, which represents
15-
# https://codequizzes.wordpress.com/2014/04/07/rubys-self-keyword-and-implicit-self/
16-
# its closure. test on tests/proc-return.rb
15+
# its closure. see tests/proc-return.rb
1716
#
1817
# - support gets() for taking user input using the restart hack mechanism
1918
# that we used for Python. user input stored in $_
@@ -36,8 +35,6 @@
3635
# with way too many attributes. this is a general problem that
3736
# manifests in other languages as well.
3837

39-
# style guide: https://github.com/styleguide/ruby
40-
4138

4239
require 'json'
4340
require 'optparse'
@@ -198,16 +195,21 @@ def encode(dat)
198195
encoded_constants << [e.to_s, encode(dat.const_get(e))]
199196
end
200197

198+
# TODO: what about if you override a class method that your
199+
# superclass defines? will we run into problems then?
201200
my_class_methods = dat.methods - dat.superclass.methods
202201
my_class_methods.each do |e|
203202
encoded_class_methods << ['self.' + e.to_s, encode(dat.method(e))]
204203
end
205204

206-
my_instance_methods = dat.instance_methods - dat.superclass.instance_methods
207-
my_instance_methods.each do |e|
208-
# use instance_method to get the unbound method
209-
# http://ruby-doc.org/core-2.2.0/UnboundMethod.html
210-
encoded_instance_methods << [e.to_s, encode(dat.instance_method(e))]
205+
dat.instance_methods.each do |e|
206+
m = dat.instance_method(e)
207+
# only add if this method belongs to YOU and not to a superclass
208+
if m.owner == dat
209+
# use instance_method to get the unbound method
210+
# http://ruby-doc.org/core-2.2.0/UnboundMethod.html
211+
encoded_instance_methods << [e.to_s, encode(m)]
212+
end
211213
end
212214

213215
dat.class_variables.each do |e|

0 commit comments

Comments
 (0)