lowtype 1.7.2 → 1.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b07cda0321f586717e03d2db76cf7e126acbec7c94f0aa210e1fa0431462ca3a
4
- data.tar.gz: 5f482ba095cdbea8bebfd2114d336897679e37b1ae3439bfc32ba9cd676c0438
3
+ metadata.gz: 551907b8ea44ce8bf3b0a7483429d1b00808a8d0426bec81f38ad9a22db5c17d
4
+ data.tar.gz: ac2261758eb31ad688162d77b6883ad8730f24d93671cbf98ec3a8c51c3a664a
5
5
  SHA512:
6
- metadata.gz: 8140b60b55aa9b046c2c3af2ae62f736ee8ef35daa04dd3a718a37af04fcb7ae8f7aab4868763bd2d14ef6937f0f8920b6618f3d55119674b7b0e78f81588cc8
7
- data.tar.gz: 31ee7e80703fe07da8864aa10d4dcbd01a565565ec7561a746064b08b1b067e00a2ad76a7f1b81bb13732fc0641377d778807a1baeeb54ca37411ec3d0cb4abc
6
+ metadata.gz: ffd707a79f5fa9b72ad9378e16fc21fd5b2d238334fee2f024bc94584bd964d1c1c3908fca691b932663ac381b395e2fc234baea5def414d178adf3320b17c92
7
+ data.tar.gz: 616fef72cfd37c55ad5c50e1bdddc590509417553419ddcc2d94ea93be183b7b68291a0154fe730e2f125699cf0e72b7e7e82b736ddf8c2bbbf0dd1f84a07f86
@@ -120,12 +120,16 @@ module Low
120
120
  # A method evaluated with "class_eval" finds constants in its class but not in the modules the class is nested in,
121
121
  # like "TrieNode" from "Rain::TrieNode", which Ruby finds for the method as written. So the method is evaluated
122
122
  # inside each module and class of the target's name. The method still reports its own file and line.
123
+ # A method in "class << self" is evaluated inside "class << self" in its class, so it finds its class's constants
124
+ # too, like "BODY_METHODS" in "Low::RequestParser", rather than only the singleton class's.
123
125
  def evaluate_nested(target:, source:, file_path:, line:)
124
- namespaces = nesting(target:)
126
+ singleton = target.singleton_class? && target.attached_object.is_a?(Module)
127
+ namespaces = nesting(target: singleton ? target.attached_object : target)
125
128
  return target.class_eval(source, file_path, line) unless namespaces
126
129
 
127
130
  opening = namespaces.map { |namespace| "#{namespace.is_a?(Class) ? 'class' : 'module'} #{namespace.name.split('::').last};" }
128
- closing = ' end;' * namespaces.size
131
+ opening << 'class << self;' if singleton
132
+ closing = ' end;' * opening.size
129
133
  TOPLEVEL_BINDING.eval("#{opening.join(' ')} #{source}\n#{closing}", file_path, line)
130
134
  end
131
135
 
data/lib/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Low
4
4
  module Type
5
- VERSION = '1.7.2'
5
+ VERSION = '1.7.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lowtype
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - maedi