choron_support 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee00806dd922746ab7a93c6835f09ddc18d78f39f34c5498abd00faad0f02948
4
- data.tar.gz: 00047a1d9e08362f7cf476518b5c67d93f490f5058260ec5abee3d363c9ccffd
3
+ metadata.gz: d7a4560cc78c0d228363cffeb410e12154e8b87dbc0069f616f902b043d1554a
4
+ data.tar.gz: 15605732d079e4d29eadd67297ee004cafd32ed1fd9e97ff6741f83d02828587
5
5
  SHA512:
6
- metadata.gz: 5142e115d399be76589e39bdf21ea33944a8cd2bc1f3f2c5bcaba15aca77ec9244d27b48325d46a3eeea6f611cc5ecc08abc0e31a920b238a0ec3ec13fbba4c7
7
- data.tar.gz: c3dadd661f9261167656b268acddf945671dea4cf9ecad9b85d12d42bfc9f11241045ec080fe58a0c39a49443ad8e69901ddf6ecb36885a6a95127b2070ac770
6
+ metadata.gz: 5e70625d4eb7fb2804bddf6f800ea7b87955a1ae9c5fe42a32982c88b38c616fd0a6c6572c7e28b2bc865c12a9ecfceab559d8ba43486702f65b54275ab689e5
7
+ data.tar.gz: bf4570b46ddc3a38853dc6083458f831c055421be55024e11e45c5c6e5e104fe4c3dde17de84239fc93ee1beb906c9506aa9f9e0211016bc087a208bfd878029
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- choron_support (0.1.5)
4
+ choron_support (0.1.7)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -2,12 +2,11 @@ require_relative "domains/base"
2
2
 
3
3
  module ChoronSupport
4
4
  module DomainDelegate
5
+ class DelegationError < NoMethodError; end
5
6
  extend ActiveSupport::Concern
6
7
 
7
8
  included do
8
- extend Forwardable
9
-
10
- # QueryオブジェクトパターンをEasyに使うためのクラスメソッドです
9
+ # 処理を別クラスに委任する設定をEasyに使うためのクラスメソッドです
11
10
  # @param [Symbol] method_name Modelに定義されるメソッド名
12
11
  # @param [Choron::Domains::Base] option domain Domainクラスを文字列で直接指定することができます。シンボルを渡すとクラス化を自動で行います。デフォルトはnilです。
13
12
  # @param [Symbol] option domain_to_method 委譲先のDomainクラスの呼び出しメソッドを指定できます。デフォルトは :call です
@@ -49,7 +48,9 @@ module ChoronSupport
49
48
  # ドメインオブジェクトにデリゲートさせます
50
49
  # 例: def_delegator :__domains_users_purchase_object__, :call, :purchase
51
50
  # purchase メソッドを __domains_xxx__ の call メソッドにデリゲートする
52
- def_delegator domain_object_method_name, to, method_symbol
51
+ define_method(method_symbol) do |*args, **keyparams, &block|
52
+ send(domain_object_method_name).send(to, *args, **keyparams, &block)
53
+ end
53
54
  end
54
55
 
55
56
  # domain_delegate とほぼ同じ動きですが、こちらはクラスメソッドをデリゲートするものです。
@@ -77,18 +78,8 @@ module ChoronSupport
77
78
  def self.class_domain_delegate(method_symbol, specific: true, class_name: nil, to: :call)
78
79
  domain_class = __generate_choron_domain_class(method_symbol, specific, class_name)
79
80
 
80
- # どのような引数でもデリゲートできるようにしています
81
- define_singleton_method(method_symbol) do |*params, **keyparams|
82
- case [!params.empty?, !keyparams.empty?]
83
- when [true, true]
84
- domain_class.new(self).send(to, *params, **keyparams)
85
- when [true, false]
86
- domain_class.new(self).send(to, *params)
87
- when [false, true]
88
- domain_class.new(self).send(to, **keyparams)
89
- else
90
- domain_class.new(self).send(to)
91
- end
81
+ define_singleton_method(method_symbol) do |*params, **keyparams, &block|
82
+ domain_class.new(self).send(to, *params, **keyparams, &block)
92
83
  end
93
84
  end
94
85
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChoronSupport
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.7"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: choron_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - mksava
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-31 00:00:00.000000000 Z
11
+ date: 2023-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport