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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/choron_support/domain_delegate.rb +7 -16
- data/lib/choron_support/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7a4560cc78c0d228363cffeb410e12154e8b87dbc0069f616f902b043d1554a
|
4
|
+
data.tar.gz: 15605732d079e4d29eadd67297ee004cafd32ed1fd9e97ff6741f83d02828587
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e70625d4eb7fb2804bddf6f800ea7b87955a1ae9c5fe42a32982c88b38c616fd0a6c6572c7e28b2bc865c12a9ecfceab559d8ba43486702f65b54275ab689e5
|
7
|
+
data.tar.gz: bf4570b46ddc3a38853dc6083458f831c055421be55024e11e45c5c6e5e104fe4c3dde17de84239fc93ee1beb906c9506aa9f9e0211016bc087a208bfd878029
|
data/Gemfile.lock
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
|
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.
|
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-
|
11
|
+
date: 2023-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|