File tree Expand file tree Collapse file tree 1 file changed +33
-5
lines changed
Expand file tree Collapse file tree 1 file changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,23 @@ If bundler is not being used to manage dependencies, install the gem by executin
1414
1515## Usage
1616
17+ Refactor ` Foo#bar ` to ` Bar ` with ` ActiveMethod `
18+
1719``` ruby
18- class ExampleMethod < ActiveMethod ::Base
20+ class Foo
21+ def bar (a , b , c: , d: )
22+ puts " a: #{ a } "
23+ puts " b: #{ b } "
24+ puts " c: #{ c } "
25+ puts " d: #{ d } "
26+ end
27+ end
28+ ```
29+
30+ Refactor to:
31+
32+ ``` ruby
33+ class Bar < ActiveMethod ::Base
1934 argument :a
2035 argument :b , default: 2
2136 keyword_argument :c
@@ -29,25 +44,38 @@ class ExampleMethod < ActiveMethod::Base
2944 end
3045end
3146
32- ExampleMethod .call(1 )
47+ class Foo
48+ def bar (* args )
49+ Bar .call(* args)
50+ end
51+
52+ # Or
53+
54+ # def bar(a, b = 2, c:, d: 4)
55+ # Bar.call(a, b, c: c, d: d)
56+ # end
57+ end
58+
59+
60+ Foo .new .bar(1 )
3361# => a: 1
3462# => b: 2
3563# => c: nil
3664# => d: 4
3765
38- ExampleMethod .call (1 , 3 )
66+ Foo . new .bar (1 , 3 )
3967# => a: 1
4068# => b: 3
4169# => c: nil
4270# => d: 4
4371
44- ExampleMethod .call (1 , 3 , c: 6 )
72+ Foo . new .bar (1 , 3 , c: 6 )
4573# => a: 1
4674# => b: 3
4775# => c: 6
4876# => d: 4
4977
50- ExampleMethod .call (1 , 3 , c: 4 , d: 5 )
78+ Foo . new .bar (1 , 3 , c: 4 , d: 5 )
5179# => a: 1
5280# => b: 3
5381# => c: 4
You can’t perform that action at this time.
0 commit comments