who_delegated 0.3.4 → 0.4.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: 24d4480ce5ad09bb027a1f95dc239a757e0bf664f814fd5c9a47fb61b87e3860
4
- data.tar.gz: a2c0e877e1a18b26029aa5563afe646e0b95d7ade629a6281f98146c0e16a54a
3
+ metadata.gz: 824595368318fdb41b9df5aa1395f72757e3b32084f91d3f53186f5ec573cc1f
4
+ data.tar.gz: e5bcb33dadac09dc8e5f72fc848e8ca89de8352a5dec33a206145fc2b159a01b
5
5
  SHA512:
6
- metadata.gz: 1349be0567dfc56c280c3fc213e7e28cfd0d8d5b5e569b03cdeb74935ea7a37343b170f08589c9270084974226bee8166162a414ffa58c53555786c4187df5c6
7
- data.tar.gz: 7bd953ff823ceecaa53934da623b05d2552b228edf8af761370adc5441ce82b2f773f6df6b814b4a1c13b23050e49608aa8b29ad8625959869e64388c3106252
6
+ metadata.gz: 0162ccf2b4518a3e9dcd0d38f1faab1a4241c689af44717228c7d5f7dd681461762422768280e890a8189656e87d9c94e564177227a8868e8aa7fb2666ed76a2
7
+ data.tar.gz: 550108ca612898136f825022ec34c1baea207822dcaca5dd7662649a711dd189b040cf0af6384083b9365f48416eec52c907707b95be037b0592e232bcbee992
data/lib/module.rb CHANGED
@@ -1,11 +1,12 @@
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
- define_method("delegated_#{prefix}#{method}?") do
9
+ define_method("delegated_#{"#{prefix == true ? to : prefix}_" if prefix}#{method}?") do
9
10
  to
10
11
  end
11
12
  end
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # reopen ActiveRecord::Base to add delegated_method? method
4
- module ActiveRecord
5
- class Base # rubocop:todo Style/Documentation
4
+ module WhoDelegated
5
+ # Extend ActiveRecord::Base with delegated_method? method
6
+ module ActiveRecordExtension
6
7
  def delegated_method?(method_name)
7
8
  respond_to?("delegated_#{method_name}?") && send("delegated_#{method_name}?")
8
9
  end
@@ -14,3 +15,5 @@ module ActiveRecord
14
15
  end
15
16
  end
16
17
  end
18
+
19
+ ActiveRecord::Base.include WhoDelegated::ActiveRecordExtension
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "who_delegated/active_record_extension"
3
4
  require "module"
4
- require "activerecord/base"
5
-
6
5
  module WhoDelegated
7
6
  class Railtie < ::Rails::Railtie
8
7
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WhoDelegated
4
- VERSION = "0.3.4"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/who_delegated.rb CHANGED
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_record/base"
4
3
  require "active_support/core_ext/module/delegation"
5
- require "who_delegated/railtie"
4
+ require "active_record/base"
6
5
  require "zeitwerk"
7
6
  loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
8
7
  loader.setup
9
-
8
+ require "who_delegated/railtie"
10
9
  module WhoDelegated # rubocop:todo Style/Documentation
11
10
  end
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.3.4
4
+ version: 0.4.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-21 00:00:00.000000000 Z
11
+ date: 2024-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -35,10 +35,10 @@ files:
35
35
  - MIT-LICENSE
36
36
  - README.md
37
37
  - Rakefile
38
- - lib/activerecord/base.rb
39
38
  - lib/module.rb
40
39
  - lib/tasks/who_delegated_tasks.rake
41
40
  - lib/who_delegated.rb
41
+ - lib/who_delegated/active_record_extension.rb
42
42
  - lib/who_delegated/railtie.rb
43
43
  - lib/who_delegated/version.rb
44
44
  homepage: https://github.com/sampokuokkanen/who_delegated
@@ -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: