super_tools 0.0.14 → 0.0.15

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
  SHA1:
3
- metadata.gz: 4629c593e7e200633427dd00312a6796f89214f0
4
- data.tar.gz: 44f7a6c84dec5dbcf3684063a822f3505dea8bc8
3
+ metadata.gz: 37be0626d7ebf5618e509581d4493e001ddf95ca
4
+ data.tar.gz: fe0ef27a8c0e9c3e68f8219a23bf8912a3c32bc1
5
5
  SHA512:
6
- metadata.gz: 748d60139166797eeef6b99493e162d411eb27a8b0600d19cc0bece66024236e8f7f2f5b2086a91eba306fbb86ce9b0585dcc0cd62fbe74342d5ff7e3dfe2af8
7
- data.tar.gz: 4f07b57896dd2fc6a1c59554365dae3c33b7d1b9756622c4fa380ba75d84731a1f4f66a7b04fbe87afd04e3a43a18dee401837364919f4d03c28ffb4bb5c8d7d
6
+ metadata.gz: b704f4409c86eef79d88cf4cc0461dcb30facf45f743a4faf9d024e0054c0024bb67344b77edd196e5580c15b0bf48074e6a4b2fc47f5884e92f648de2874b78
7
+ data.tar.gz: be2a3df596dbda74630634eedbf863aea5c03294187be6007d73e282955b73354b176826c2b3f3f650b6d38a0daf21a624fee1e4ff828a4544bf4d210ea40e07
@@ -144,7 +144,7 @@ GEM
144
144
  nio4r (2.3.1)
145
145
  nokogiri (1.9.1)
146
146
  mini_portile2 (~> 2.4.0)
147
- rack (2.0.7)
147
+ rack (2.0.8)
148
148
  rack-test (1.1.0)
149
149
  rack (>= 1.0, < 3)
150
150
  rails (5.2.3)
@@ -7,28 +7,39 @@ module SuperForm
7
7
 
8
8
  define_callbacks :transaction, :queries, :validations
9
9
 
10
- def self.before_transaction(method_name)
11
- set_callback :transaction, :before, method_name
10
+ def self.before_transaction(method_name=nil, &block)
11
+ set_defined_callback(:transaction, :before, method_name, &block)
12
12
  end
13
13
 
14
- def self.before_queries(method_name)
15
- set_callback :queries, :before, method_name
14
+ def self.before_queries(method_name=nil, &block)
15
+ set_defined_callback(:queries, :before, method_name, &block)
16
16
  end
17
17
 
18
- def self.before_commit(method_name)
19
- set_callback :queries, :after, method_name
18
+ def self.before_commit(method_name=nil, &block)
19
+ set_defined_callback(:queries, :after, method_name, &block)
20
20
  end
21
21
 
22
- def self.after_commit(method_name)
23
- set_callback :transaction, :after, method_name
22
+ def self.after_commit(method_name=nil, &block)
23
+ set_defined_callback(:transaction, :after, method_name, &block)
24
24
  end
25
25
 
26
- def self.before_validations(method_name)
27
- set_callback :validations, :after, method_name
26
+ def self.before_validations(method_name=nil, &block)
27
+ set_defined_callback(:validations, :before, method_name, &block)
28
28
  end
29
29
 
30
- def self.after_validations(method_name)
31
- set_callback :validations, :after, method_name
30
+ def self.after_validations(method_name=nil, &block)
31
+ set_defined_callback(:validations, :after, method_name, &block)
32
+ end
33
+
34
+ protected
35
+
36
+ def self.set_defined_callback(event, callback, method_name=nil, &block)
37
+ raise "wrong number of arguments ('method_name' or 'block' choose one)" if method_name.nil? == false && block.present?
38
+ if block_given?
39
+ set_callback event, callback, &block
40
+ else
41
+ set_callback event, callback, method_name
42
+ end
32
43
  end
33
44
  end
34
45
 
@@ -1,5 +1,7 @@
1
1
  module SuperInteraction
2
- class Engine < Rails::Engine
3
- paths["app/views"] = "lib/super_interaction/views"
2
+ if defined?(Rails::Engine)
3
+ class Engine < Rails::Engine
4
+ paths["app/views"] = "lib/super_interaction/views"
5
+ end
4
6
  end
5
7
  end
@@ -1,3 +1,3 @@
1
1
  module SuperTools
2
- VERSION = '0.0.14'
2
+ VERSION = '0.0.15'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - eddie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-31 00:00:00.000000000 Z
11
+ date: 2020-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler