active_method 1.3.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +4 -2
- data/lib/active_method/base.rb +17 -17
- data/lib/active_method/version.rb +1 -1
- data/matrixeval.yml +7 -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: 8c0688ad78d8a0b27bd65cb414eb2815684a86e415a50de9858f1e9a0bccaa91
|
4
|
+
data.tar.gz: f4d248efb0782cf91cd1476537dbc31bf3b43373813bae9dd25444651a8d9dae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a4aaea9111161b1a672ee7eecced37c7654c0ec684f82f3b4469df8577dd050fe1066a7559561094d9faf62daa8c53e3fb19a43f54645bca4667a5d849edc90
|
7
|
+
data.tar.gz: adeb5ec18322b51f25bfd998859329b246cf5d2cc06818ab93e09e040dd9ddf10959ec72be56aa6f9452eb61c605c19d08af95d37da1a31efc4aa94aec9167d0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -52,7 +52,7 @@ User.new.foo('aa', 3, c: 'cc', d: 5)
|
|
52
52
|
#=> a: aa, b: 3, c: cc, d: 5
|
53
53
|
```
|
54
54
|
|
55
|
-
###
|
55
|
+
### Customize the owner name of the method
|
56
56
|
|
57
57
|
```ruby
|
58
58
|
class User
|
@@ -63,8 +63,10 @@ class User
|
|
63
63
|
end
|
64
64
|
|
65
65
|
class Hi < ActiveMethod::Base
|
66
|
+
onwer :support
|
67
|
+
|
66
68
|
def call
|
67
|
-
puts "Hi, I'm a #{
|
69
|
+
puts "Hi, I'm a #{support.fromal_name}. Please call me #{user.name}"
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
data/lib/active_method/base.rb
CHANGED
@@ -22,16 +22,17 @@ module ActiveMethod
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def arguments
|
25
|
-
|
25
|
+
@arguments ||= {}
|
26
26
|
end
|
27
27
|
|
28
28
|
def keyword_arguments
|
29
|
-
|
29
|
+
@keyword_arguments ||= []
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
32
|
+
def owner_name
|
33
|
+
return @owner_name unless @owner_name.nil?
|
34
|
+
return if self == ActiveMethod::Base
|
35
|
+
superclass.owner_name
|
35
36
|
end
|
36
37
|
|
37
38
|
protected
|
@@ -42,6 +43,8 @@ module ActiveMethod
|
|
42
43
|
parse_argument(method_name, *args)
|
43
44
|
when 'keyword_argument'
|
44
45
|
parse_keyword_argument(*args)
|
46
|
+
when 'owner'
|
47
|
+
parse_method_owner(*args)
|
45
48
|
else
|
46
49
|
super
|
47
50
|
end
|
@@ -67,17 +70,10 @@ module ActiveMethod
|
|
67
70
|
end
|
68
71
|
end
|
69
72
|
|
70
|
-
def
|
71
|
-
|
72
|
-
|
73
|
-
self.class_variable_set(:@@arguments, {})
|
73
|
+
def parse_method_owner(name)
|
74
|
+
@owner_name = name
|
74
75
|
end
|
75
76
|
|
76
|
-
def init_keyword_arguments
|
77
|
-
return if self.class_variable_defined?(:@@keyword_arguments)
|
78
|
-
|
79
|
-
self.class_variable_set(:@@keyword_arguments, [])
|
80
|
-
end
|
81
77
|
end
|
82
78
|
|
83
79
|
def initialize(*args)
|
@@ -104,9 +100,13 @@ module ActiveMethod
|
|
104
100
|
def __set_owner(owner)
|
105
101
|
@__method_owner = owner
|
106
102
|
|
107
|
-
|
108
|
-
|
109
|
-
|
103
|
+
@__owner_name = self.class.owner_name
|
104
|
+
if @__owner_name.nil?
|
105
|
+
klass = owner.is_a?(Class) ? owner : owner.class
|
106
|
+
@__owner_name = Util.snake_case(klass.name.split("::").last)
|
107
|
+
end
|
108
|
+
|
109
|
+
self.define_singleton_method @__owner_name do
|
110
110
|
@__method_owner
|
111
111
|
end
|
112
112
|
end
|
data/matrixeval.yml
CHANGED
@@ -18,9 +18,15 @@ matrix:
|
|
18
18
|
container:
|
19
19
|
image: ruby:3.0.4
|
20
20
|
- key: 3.1
|
21
|
-
default: true
|
22
21
|
container:
|
23
22
|
image: ruby:3.1.2
|
23
|
+
- key: 3.2
|
24
|
+
container:
|
25
|
+
image: ruby:3.2.4
|
26
|
+
- key: 3.3
|
27
|
+
default: true
|
28
|
+
container:
|
29
|
+
image: ruby:3.3.4
|
24
30
|
# - key: jruby-9.3
|
25
31
|
# container:
|
26
32
|
# image: jruby:9.3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_method
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hopper Gee
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Refactor your obscure method to a method object
|
14
14
|
email:
|