short_circu_it 0.4.3 → 0.5.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
  SHA256:
3
- metadata.gz: c832a06a29ef0166c784109b5e2f45a95eee011276285cf319ecd4374ad5ba32
4
- data.tar.gz: 0aa458a572070fa87dde666601b76dff83fc7a494e967706eb419bd3d062b8af
3
+ metadata.gz: 592a5e9f48efa007083f97ccf469ab400f526fc3f422a6db53fccd29974548b2
4
+ data.tar.gz: 5903506ebb5f4cb60e6e6e9cda050e1b62e3bfd33884fce201ce6c0416378d07
5
5
  SHA512:
6
- metadata.gz: b7aa7719d312093ebc06378b3bbd4d503f2b36f8c87bdb67d0bef1288fa32591ae46559b9bc541868ddb294bf46666b81fc07607b73e5240ef29d75e63e59261
7
- data.tar.gz: dfddd1772a79e86cda946fdabc1223195a5426750aaa2a1eda65a2ff938da315729acf051d228e2e26e5f385ad6e35d3755c7bb69715b20728f1a783d21d1cde
6
+ metadata.gz: fc96ea51eeec2ad20ec71040b1cf3a5748a84051cb24999618a034d02d97f7bcbf060aefc1431cb9ca32c340abb62afdf94ca315baa74e77dd98c7f112002bbf
7
+ data.tar.gz: 71b657f2dc9a749004f69bd5e0df34adae263d9ecfeb6a7dec47a61c7db359a540ab137b3eb9ffa731057eca3a43e460ab32db2abf9f4dd5ff7e5b8a24cab4df
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShortCircuIt
4
- VERSION = "0.4.3"
4
+ VERSION = "0.5.0"
5
5
  end
@@ -12,8 +12,6 @@ module ShortCircuIt
12
12
  extend ActiveSupport::Concern
13
13
  include AroundTheWorld
14
14
 
15
- PREPEND_MODULE_NAME = "MemoizedMethods"
16
-
17
15
  included do
18
16
  delegate :memoization_observers, to: :class
19
17
  delegate :clear_memoization, :clear_all_memoization, to: :memoization_store
@@ -27,7 +25,10 @@ module ShortCircuIt
27
25
  end
28
26
 
29
27
  class_methods do
30
- attr_internal_reader :memoization_observers
28
+ def memoization_observers
29
+ @memoization_observers ||=
30
+ superclass.respond_to?(:memoization_observers) ? superclass.memoization_observers : {}
31
+ end
31
32
 
32
33
  protected
33
34
 
@@ -71,7 +72,7 @@ module ShortCircuIt
71
72
  def memoize(method_name, observes: :itself)
72
73
  add_memoized_observers(method_name.to_sym, observes)
73
74
 
74
- around_method method_name.to_sym, PREPEND_MODULE_NAME do |*args|
75
+ around_method method_name.to_sym, prevent_double_wrapping_for: ShortCircuIt do |*args|
75
76
  memoization_store.memoize(method_name.to_sym, args.hash) do
76
77
  super(*args)
77
78
  end
@@ -80,11 +81,10 @@ module ShortCircuIt
80
81
 
81
82
  private
82
83
 
83
- attr_internal_writer :memoization_observers
84
+ attr_writer :memoization_observers
84
85
 
85
86
  def add_memoized_observers(method_name, observers)
86
87
  # TODO: Raise an error if method has already been memoized? A warning maybe?
87
- self.memoization_observers ||= {}
88
88
  self.memoization_observers = memoization_observers.
89
89
  merge(method_name.to_sym => Array.wrap(observers).freeze).
90
90
  freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: short_circu_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allen Rettberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-10 00:00:00.000000000 Z
11
+ date: 2018-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.4.3
33
+ version: 0.5.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.4.3
40
+ version: 0.5.0
41
41
  description: Memoize methods safely with parameter and dependency observation
42
42
  email:
43
43
  - allen.rettberg@freshly.com