who_delegated 0.3.5 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/module.rb +6 -1
- data/lib/who_delegated/active_record_extension.rb +2 -1
- data/lib/who_delegated/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f855d48a56878ec7dd784743524fd00ff6bc1d3d02de09fd1def373785c8fc11
|
4
|
+
data.tar.gz: bdb870c715b8db194db9986333931b843409ef74196f7e6e164863964a250649
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e9dbea9d0bbcff53d237527fcc2b54b153d8504834a1bb20dcdad65266808d24a3493850e20afd2d9ad2908cd7c0d6d5176b0d982fac5fa5a6a388281d42ff0
|
7
|
+
data.tar.gz: c8ac87b2c12eb9e7c3ad2155d255d2e6ac81550ab65c674d55733f9f51949ee416f12802d439f3da7b3b90f94ccc661db8867526482765b751a4fa173745e452
|
data/lib/module.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# reopen Module from ActiveSupport
|
3
4
|
class Module
|
4
5
|
alias __delegate delegate
|
5
6
|
def delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil)
|
6
7
|
if defined?(ActiveRecord::Base) && self < ActiveRecord::Base
|
7
8
|
methods.each do |method|
|
8
|
-
|
9
|
+
method_name = "delegated_#{"#{prefix == true ? to : prefix}_" if prefix}#{method}?"
|
10
|
+
define_singleton_method(method_name) do
|
11
|
+
respond_to?(method)
|
12
|
+
end
|
13
|
+
define_method(method_name) do
|
9
14
|
to
|
10
15
|
end
|
11
16
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
# reopen ActiveRecord::Base to add delegated_method? method
|
4
4
|
module WhoDelegated
|
5
|
+
# Extend ActiveRecord::Base with delegated_method? method
|
5
6
|
module ActiveRecordExtension
|
6
7
|
def delegated_method?(method_name)
|
7
8
|
respond_to?("delegated_#{method_name}?") && send("delegated_#{method_name}?")
|
@@ -15,4 +16,4 @@ module WhoDelegated
|
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
|
-
ActiveRecord::Base.
|
19
|
+
ActiveRecord::Base.include WhoDelegated::ActiveRecordExtension
|
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.0
|
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
|
@@ -48,6 +48,7 @@ metadata:
|
|
48
48
|
homepage_uri: https://github.com/sampokuokkanen/who_delegated
|
49
49
|
source_code_uri: https://github.com/sampokuokkanen/who_delegated
|
50
50
|
changelog_uri: https://github.com/sampokuokkanen/who_delegated/blob/main/CHANGELOG.md
|
51
|
+
rubygems_mfa_required: 'false'
|
51
52
|
post_install_message:
|
52
53
|
rdoc_options: []
|
53
54
|
require_paths:
|