active_method 1.0.0 → 1.1.1

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: 223f8bbbc57474a6cc9d23abcc64e3e813897cb351e1ffd2ff80405e3e6e6769
4
- data.tar.gz: 75b7a12d9080d3e268be90cf9cca439e946312758c5c72720482761abed1e01c
3
+ metadata.gz: 403381f7108f07fea213db2b68c9abc71277b1e50e523a7c15118920c186bbd5
4
+ data.tar.gz: e87f9c937daf923d37934de40d04bb24adecc5c2bdcd8ce2eadbe7d3d302df27
5
5
  SHA512:
6
- metadata.gz: aefd7ff1a3160ea7b59cccd3ddb5b1b2baed523a34557f1df65db497df66f89501fb8ded964776e3abc2faac8ca8665e70ea6c17f786b99f54810e1420cf662c
7
- data.tar.gz: c5294d303371c0e9e8da8840131b13abb0cbc694ecd2d423f848373ececbc51689198800d81c7275834520378333ccf5ae0f92b11ae1f4b304f74fed20925e2d
6
+ metadata.gz: e64c462061a8e6e574ebf345ee48cd4a450925acc6260b2c1ffa9f4d905bf5c9c72c773a6023eefc0d6805798d642285eaee59f7d946adaec2cefa0bb5306c93
7
+ data.tar.gz: 350d6b978759a527f0a613b292297c361f939e2081b40721d9693baed446f5918ea63065fe2f3437d965a392b5d1d5e95f6377e818985f11e4429e924fd28567
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.1.1] - 2022-10-08
4
+
5
+ - Change owner method define from `self.calss.define_method` to `self.define_singleton_method`
6
+
7
+ ## [1.1.0] - 2022-10-08
8
+
9
+ - Support `module_function`
10
+
3
11
  ## [1.0.0] - 2022-09-16
4
12
 
5
13
  - Now you can use `.active_method` through `include ActiveMethod`
data/README.md CHANGED
@@ -87,6 +87,27 @@ Bar.call(1, 3, c: 4, d: 5)
87
87
  # => buzz
88
88
  ```
89
89
 
90
+ ### Work on module
91
+
92
+ ```ruby
93
+ class Hi < ActiveMethod::Base
94
+ argument :name
95
+
96
+ def call
97
+ "Hi, #{name}"
98
+ end
99
+ end
100
+
101
+ module Say
102
+ include ActiveMethod
103
+
104
+ active_method :hi, module_function: true
105
+ end
106
+
107
+ Say.hi('John')
108
+ # => "Hi, John"
109
+ ```
110
+
90
111
  ## Development
91
112
 
92
113
  ```bash
@@ -105,7 +105,7 @@ module ActiveMethod
105
105
  @__method_owner = owner
106
106
 
107
107
  instance_name = Util.snake_case(owner.class.name.split("::").last)
108
- self.class.define_method instance_name do
108
+ self.define_singleton_method instance_name do
109
109
  @__method_owner
110
110
  end
111
111
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveMethod
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.1"
5
5
  end
data/lib/active_method.rb CHANGED
@@ -12,12 +12,16 @@ module ActiveMethod
12
12
  end
13
13
 
14
14
  module ClassMethods
15
- def active_method(name, method_class = nil)
15
+ def active_method(name, method_class = nil, **options)
16
16
  method_class ||= Util.constantize self, Util.camel_case(name)
17
17
 
18
18
  define_method name do |*args|
19
19
  method_class[self].call(*args)
20
20
  end
21
+
22
+ if options[:module_function]
23
+ module_function name
24
+ end
21
25
  end
22
26
  end
23
27
  end
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.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hopper Gee
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-15 00:00:00.000000000 Z
11
+ date: 2022-10-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Refactor your obscure method to a method object
14
14
  email:
@@ -20,7 +20,6 @@ files:
20
20
  - CHANGELOG.md
21
21
  - CODE_OF_CONDUCT.md
22
22
  - Gemfile
23
- - Gemfile.lock
24
23
  - LICENSE.txt
25
24
  - README.md
26
25
  - Rakefile
data/Gemfile.lock DELETED
@@ -1,50 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- active_method (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- concurrent-ruby (1.1.10)
10
- debug (1.6.2)
11
- irb (>= 1.3.6)
12
- reline (>= 0.3.1)
13
- docile (1.4.0)
14
- io-console (0.5.11)
15
- irb (1.4.1)
16
- reline (>= 0.3.0)
17
- matrixeval (0.4.3)
18
- concurrent-ruby
19
- rainbow (~> 3.1)
20
- terminal-table
21
- matrixeval-ruby (0.4.0)
22
- matrixeval (~> 0.4.2)
23
- minitest (5.16.2)
24
- rainbow (3.1.1)
25
- rake (13.0.6)
26
- reline (0.3.1)
27
- io-console (~> 0.5)
28
- simplecov (0.21.2)
29
- docile (~> 1.1)
30
- simplecov-html (~> 0.11)
31
- simplecov_json_formatter (~> 0.1)
32
- simplecov-html (0.12.3)
33
- simplecov_json_formatter (0.1.4)
34
- terminal-table (3.0.2)
35
- unicode-display_width (>= 1.1.1, < 3)
36
- unicode-display_width (2.2.0)
37
-
38
- PLATFORMS
39
- arm64-darwin-21
40
-
41
- DEPENDENCIES
42
- active_method!
43
- debug
44
- matrixeval-ruby
45
- minitest (~> 5.0)
46
- rake (~> 13.0)
47
- simplecov
48
-
49
- BUNDLED WITH
50
- 2.3.12