who_delegated 0.4.0 → 0.5.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 504f89f7944d42b4364574258fa1b8acd06eb515d40b134ce3e79c884b99f6df
|
4
|
+
data.tar.gz: 17a927dd406a679ec8a64fd2b81f09ba48144861a39977a0806b0ac4ce8c17af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 617a65f28d26ba6f72505b74d0d0b1c9d4d2cd5a3c6ed16516ed4267fc90f3f45e3ed4ffaeb448a2a65c8dadf2cf6d1098f1fd76bbec28d9846fd77735b68e8b
|
7
|
+
data.tar.gz: 141682d24a35be5686b64a07c3e0a891f07dfdebaa41ee3644154bc517a55f1cb6ab5aa5dcf188690a3309245b3fe5073c475c956e876cc7368ba80fbd3749bc
|
data/lib/module.rb
CHANGED
@@ -6,7 +6,11 @@ class Module
|
|
6
6
|
def delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil)
|
7
7
|
if defined?(ActiveRecord::Base) && self < ActiveRecord::Base
|
8
8
|
methods.each do |method|
|
9
|
-
|
9
|
+
method_name = "delegated_#{"#{prefix == true ? to : prefix}_" if prefix}#{method}?"
|
10
|
+
define_singleton_method(method_name) do
|
11
|
+
to
|
12
|
+
end
|
13
|
+
define_method(method_name) do
|
10
14
|
to
|
11
15
|
end
|
12
16
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WhoDelegated
|
4
|
+
module ActiveRecordExtensionClassMethods
|
5
|
+
def delegated_method?(method_name)
|
6
|
+
respond_to?("delegated_#{method_name}?") && send("delegated_#{method_name}?")
|
7
|
+
end
|
8
|
+
|
9
|
+
def delegated_target(method_name)
|
10
|
+
return unless delegated_method?(method_name)
|
11
|
+
|
12
|
+
send("delegated_#{method_name}?")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
ActiveRecord::Base.extend WhoDelegated::ActiveRecordExtensionClassMethods
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: who_delegated
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sampo Kuokkanen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- lib/tasks/who_delegated_tasks.rake
|
40
40
|
- lib/who_delegated.rb
|
41
41
|
- lib/who_delegated/active_record_extension.rb
|
42
|
+
- lib/who_delegated/active_record_extension_class_methods.rb
|
42
43
|
- lib/who_delegated/railtie.rb
|
43
44
|
- lib/who_delegated/version.rb
|
44
45
|
homepage: https://github.com/sampokuokkanen/who_delegated
|