delorean_lang 0.6.2 → 0.6.3

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
- SHA1:
3
- metadata.gz: dc3121e44387a45ece005a722586333a2295387e
4
- data.tar.gz: 2e1b848d412048005a090e1d4f01b30947c66b3f
2
+ SHA256:
3
+ metadata.gz: 2c68ada6d28bb5e65382a50c03e73518273929711569c689cba11387583cc5c9
4
+ data.tar.gz: 6a5ec88595b66cfc946f03337bdec9dc470ea8f1d31f47820b82424b8d039ffe
5
5
  SHA512:
6
- metadata.gz: 6f740308a6897431f6f1e3ca0e62398c8ddea7ea061f21d71dff0b25ae9918fb1f12f5412a76a5a4fe6e2792380564cd0507a74bfb93b23e7ced727cf87e9fbf
7
- data.tar.gz: 7021d7fe15ff933ef6bb97dbb5a51da546214aaa8ce682166094d73f2d3e7edb358daa9769291b85a1c0d7939e60998ee21caddfbb400b22184cc2a07c5730a8
6
+ metadata.gz: 1f49e8633ba3e904ee9341f97682773919cb546316e6a06eab3dc5fa575c63a57720e2fb4bf5f95a5bf9f8b465cf525305232e00fa4eeac2a4fcb3d26dbcdff0
7
+ data.tar.gz: f17a7f9f187a55fca8ba0c4d1dad11c7f4c62d265f4c92e8fbafb92c932bda6d8c1d935a9d70e876c3c3d65f9fe74e32fc94d2c2b59d54fa98fb671db75fc00d
@@ -7,12 +7,16 @@ module Delorean
7
7
  module Whitelists
8
8
  module Matchers
9
9
  class Method
10
- attr_reader :method_name, :match_to, :arguments_matchers
10
+ attr_reader :method_name,
11
+ :match_to,
12
+ :arguments_matchers,
13
+ :arguments_matchers_hash
11
14
 
12
15
  def initialize(method_name:, match_to: nil)
13
16
  @method_name = method_name
14
17
  @match_to = match_to
15
18
  @arguments_matchers = []
19
+ @arguments_matchers_hash = {}
16
20
 
17
21
  yield self if block_given?
18
22
  end
@@ -22,6 +26,8 @@ module Delorean
22
26
  called_on: klass, method_name: method_name, with: with
23
27
  )
24
28
 
29
+ arguments_matchers_hash[klass] = matcher
30
+
25
31
  arguments_matchers << matcher
26
32
 
27
33
  # Sort matchers by reversed ancestors chain length, so
@@ -32,7 +38,12 @@ module Delorean
32
38
  end
33
39
 
34
40
  def matcher(klass:)
35
- matcher = arguments_matchers.find do |matcher_object|
41
+ # Optimization hack: Look for exact class matcher in hash.
42
+ # If it's not found, search for ancestor classes matchers in array
43
+ matcher = @arguments_matchers_hash[klass]
44
+ return matcher unless matcher.nil?
45
+
46
+ matcher = @arguments_matchers.find do |matcher_object|
36
47
  klass <= matcher_object.called_on
37
48
  end
38
49
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Delorean
4
- VERSION = '0.6.2'
4
+ VERSION = '0.6.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delorean_lang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arman Bostani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-30 00:00:00.000000000 Z
11
+ date: 2019-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  version: '0'
193
193
  requirements: []
194
194
  rubyforge_project:
195
- rubygems_version: 2.6.14
195
+ rubygems_version: 2.7.8
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: Delorean compiler