embed_callbacks 0.1.3 → 1.0.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: 4ece6d51dea6b1fd8807f524e2fd0a3800febf432d35d77bc9c42d4dedf46b22
4
- data.tar.gz: 66b28ee66187815bc5815d24b911a683634bac23227b441b4d0504fc48bbcf2c
3
+ metadata.gz: cb4024b98fbb4162674d0e91eed1810871d8e4e461b187dac5351a76587fea31
4
+ data.tar.gz: 75d2896de526c3399ac32bddb5d0f1501fee2a81c0b1adf0712e9a3bf0223fd8
5
5
  SHA512:
6
- metadata.gz: ed85d2e97517dba9d9d83b3e72f78abc06181fc7d393d2699c19066ecc2e0dbe506d9d6def0d02f31b74c4cbfe79ab01119bd18d78cc2553f5c679ccb9ea3c15
7
- data.tar.gz: 82b091603254ec073d7eb9cbf711eae641374008d9b6b5778a70d8fd148e5a8a3c66b2a6462786523248a0177cd1ad5b06def18720e9cd199605a54e6930ea6d
6
+ metadata.gz: 71dfcfe4ebdd14d12fd89b13961286a31aa5946ad5bcf0b26686282580403526acc5c1d26a38b7523631181912841813827ffb27ae9b9b6644888cbb05655d85
7
+ data.tar.gz: c30558309347cbee8462d8d06081900bb95c0fbaa9920ae5e5bde29bbe7ea4f5afc5518607d6f20e155011af270208d19cd646ffb75459add3808ab36513f2a1
data/README.md CHANGED
@@ -41,7 +41,7 @@ require 'embed_callbacks'
41
41
 
42
42
  class Sample
43
43
  include EmbedCallbacks
44
- set_callback :target, :before, :before_callback
44
+ embed_callback :target, :before, :before_callback
45
45
 
46
46
  def target
47
47
  puts 'target'
@@ -65,7 +65,7 @@ require 'embed_callbacks'
65
65
 
66
66
  class Sample
67
67
  include EmbedCallbacks
68
- set_callback :target, :after, :after_callback
68
+ embed_callback :target, :after, :after_callback
69
69
 
70
70
  def target
71
71
  puts 'target'
@@ -89,7 +89,7 @@ require 'embed_callbacks'
89
89
 
90
90
  class Sample
91
91
  include EmbedCallbacks
92
- set_callback :target, :around, :around_callback
92
+ embed_callback :target, :around, :around_callback
93
93
 
94
94
  def target
95
95
  puts 'target'
@@ -113,7 +113,7 @@ require 'embed_callbacks'
113
113
 
114
114
  class Sample
115
115
  include EmbedCallbacks
116
- set_callback :target, :rescue, :rescue_callback
116
+ embed_callback :target, :rescue, :rescue_callback
117
117
 
118
118
  def target
119
119
  raise 'target'
@@ -138,7 +138,7 @@ require 'embed_callbacks'
138
138
 
139
139
  class Sample
140
140
  include EmbedCallbacks
141
- set_callback :target, :ensure, :ensure_callback
141
+ embed_callback :target, :ensure, :ensure_callback
142
142
 
143
143
  def target
144
144
  puts 'target'
@@ -164,7 +164,7 @@ class Sample
164
164
  include EmbedCallbacks
165
165
  attr_accessor :check_flag
166
166
 
167
- set_callback :target, :before, :before_callback, if: ->(record) { record.check_flag }
167
+ embed_callback :target, :before, :before_callback, if: ->(record) { record.check_flag }
168
168
 
169
169
  def target
170
170
  puts 'target'
@@ -1,5 +1,5 @@
1
1
  class Behavior
2
- KINDS = %i(before after around rescue ensure)
2
+ KINDS = %i(before after around rescue ensure).freeze
3
3
 
4
4
  def initialize(behavior)
5
5
  @behavior = behavior
@@ -6,8 +6,9 @@ class Condition
6
6
  end
7
7
 
8
8
  def call(record)
9
- return @if.call(record) if @if
9
+ return @if.call(record) if @if
10
10
  return !@unless&.call(record) if @unless
11
+
11
12
  true
12
13
  end
13
14
  end
@@ -1,3 +1,3 @@
1
1
  module EmbedCallbacks
2
- VERSION = "0.1.3"
2
+ VERSION = "1.0.0".freeze
3
3
  end
@@ -8,7 +8,7 @@ module EmbedCallbacks
8
8
  end
9
9
 
10
10
  module PrependMethods
11
- def set_callback(target_method_name, behavior_sym, callback_function_name, **options)
11
+ def embed_callback(target_method_name, behavior_sym, callback_function_name, **options)
12
12
  behavior = Behavior.new(behavior_sym)
13
13
  m = Module.new
14
14
  m.define_method(target_method_name) do |*params|
@@ -28,5 +28,4 @@ module EmbedCallbacks
28
28
  prepend m
29
29
  end
30
30
  end
31
-
32
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embed_callbacks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hotoolong
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-09 00:00:00.000000000 Z
11
+ date: 2023-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake