who_delegated 0.1.0 → 0.3.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: ff8900cab08a42676dba8802a3a9864c4ddfcca683836e82e7ef77bfaa5ddd9d
4
- data.tar.gz: 666641bf2f910165ffcdc16c35269110e612608e77b6ef029674ef56985a3e35
3
+ metadata.gz: 4161841870ab675f870f53fe31cc219308c0a49662e7b6d508c27c4668f2ee9a
4
+ data.tar.gz: b2983dd4d7d41aed4fe7889c46effe5845e74d6618369fb3d8149d2957dd5172
5
5
  SHA512:
6
- metadata.gz: f3fed141d4e32b25ed23977388d76b71a77edc21d3b2e1bca1ddf09db447ca5a22a9ed8661540b99c87bd42ab79d2219fb75621a9cc04219463c782c7e7f56f1
7
- data.tar.gz: '08e48fff955609091bcbcfce147962218bc673fd7e4dcb451ce8b439bd6c9890f78e5a6f6feac8d62968c4b2efac0311d3e8f17a9a54f4158e4741a625be4d96'
6
+ metadata.gz: b0b04d4eadfdbca7697e257be8c06bc349ae51dd4963d2f8cd7e78a0108bb0a10c503f5e2cc6af6439088a33165a54a9c8eea427f9224d6bdf05c739c84d1517
7
+ data.tar.gz: fd097defad5ed513070946899607c4d219220a18267e36d7b03a1916631212c7eb015075daf36a3bc8c7ea28697bc3ebbf99a349826709ced36b2e72bb2e3ab5
@@ -6,5 +6,11 @@ module ActiveRecord
6
6
  def delegated_method?(method_name)
7
7
  respond_to?("delegated_#{method_name}?") && send("delegated_#{method_name}?")
8
8
  end
9
+
10
+ def delegated_target(method_name)
11
+ return unless delegated_method?(method_name)
12
+
13
+ send("delegated_#{method_name}?")
14
+ end
9
15
  end
10
16
  end
@@ -1,13 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # reopen Module from ActiveSupport to redefine delegate method
4
3
  class Module
5
4
  alias __delegate delegate
6
5
  def delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil)
7
6
  if defined?(ActiveRecord::Base) && self < ActiveRecord::Base
8
7
  methods.each do |method|
9
8
  define_method("delegated_#{prefix}#{method}?") do
10
- true
9
+ to
11
10
  end
12
11
  end
13
12
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "who_delegated/core_ext"
3
+ require "who_delegated/module"
4
4
  require "who_delegated/activerecord/base"
5
5
 
6
6
  module WhoDelegated
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WhoDelegated
4
- VERSION = "0.1.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: who_delegated
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampo Kuokkanen
@@ -38,7 +38,7 @@ files:
38
38
  - lib/tasks/who_delegated_tasks.rake
39
39
  - lib/who_delegated.rb
40
40
  - lib/who_delegated/activerecord/base.rb
41
- - lib/who_delegated/core_ext.rb
41
+ - lib/who_delegated/module.rb
42
42
  - lib/who_delegated/railtie.rb
43
43
  - lib/who_delegated/version.rb
44
44
  homepage: https://github.com/sampokuokkanen/who_delegated