sinclair 1.9.0 → 1.10.0

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/README.md +2 -2
  4. data/config/yardstick.yml +7 -1
  5. data/lib/sinclair/configurable.rb +2 -0
  6. data/lib/sinclair/equals_checker.rb +2 -0
  7. data/lib/sinclair/matchers/add_class_method.rb +27 -36
  8. data/lib/sinclair/matchers/add_instance_method.rb +59 -59
  9. data/lib/sinclair/matchers/add_method.rb +33 -35
  10. data/lib/sinclair/matchers/change_class_method.rb +22 -16
  11. data/lib/sinclair/matchers/change_instance_method.rb +46 -16
  12. data/lib/sinclair/matchers.rb +2 -8
  13. data/lib/sinclair/method_builder/call_method_builder.rb +49 -0
  14. data/lib/sinclair/method_builder.rb +4 -1
  15. data/lib/sinclair/method_definition/call_definition.rb +52 -0
  16. data/lib/sinclair/method_definition/string_definition.rb +0 -2
  17. data/lib/sinclair/method_definition.rb +40 -24
  18. data/lib/sinclair/method_definitions.rb +21 -1
  19. data/lib/sinclair/options/builder.rb +8 -0
  20. data/lib/sinclair/options.rb +1 -13
  21. data/lib/sinclair/version.rb +1 -1
  22. data/spec/integration/yard/sinclair/matchers/change_class_method_spec.rb +24 -0
  23. data/spec/integration/yard/sinclair/matchers/change_instance_method_spec.rb +40 -0
  24. data/spec/lib/sinclair/method_builder/call_method_builder_spec.rb +76 -0
  25. data/spec/lib/sinclair/method_builder_spec.rb +63 -20
  26. data/spec/lib/sinclair/method_definition/call_definition_spec.rb +36 -0
  27. data/spec/lib/sinclair/method_definition_spec.rb +64 -0
  28. data/spec/lib/sinclair/method_definitions_spec.rb +79 -0
  29. data/spec/lib/sinclair/options/builder_spec.rb +13 -0
  30. data/spec/lib/sinclair/options/class_methods_spec.rb +23 -8
  31. data/spec/support/shared_examples/attribute_accessor.rb +103 -0
  32. metadata +9 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23c4aa7f5d3c743f783dc6196e0799bbef94fa2c4f42825379c4cc61aad8e9ec
4
- data.tar.gz: 4aa6481202521cc4c0cf8b0210e798a8d56344a43c42e41157ae7a3121ea67a4
3
+ metadata.gz: 4a3575c54efcf82ce477b70a6a34b6f6d37d6242b2c272454b141942ee90e381
4
+ data.tar.gz: fdae2230f95d50d239537f01dace6b278b7930cef96115667b424910d7106c78
5
5
  SHA512:
6
- metadata.gz: 3b07675d7768ea9db9e858498863fec96959e209b2bf9596f78e4f57ff2134f286723d8d7d3c42b9be5f8efc907602dee83dc3d0914473cc73c163a65362e84f
7
- data.tar.gz: 8f596032dfad280158eeeb5a4a74400386f960010b86480608864d81d9c017ad6fdcd8fcabf01d97ef9987a333719561f59d883840514fc707d076872760d195
6
+ metadata.gz: 424c2bd3b847482b32b45da5f3778c724c967fff11a14fdb5664e1d9b61fd0c484dc00e5f938739ffa46d3f04fcce7614ee9ed55b2fa3c3151af24a543b9d20e
7
+ data.tar.gz: 5094b1a51ae631f01163015b97131f7aaf78b349ca959f326823939de6b4205da8d64d750fad32837bdb28e74b76888644cf1518d9d51cdd2baba5318f61e595
data/.rubocop.yml CHANGED
@@ -40,7 +40,7 @@ RSpec/MultipleExpectations:
40
40
  - spec/lib/sinclair_spec.rb
41
41
 
42
42
  RSpec/NestedGroups:
43
- Max: 4
43
+ Max: 5
44
44
  Exclude:
45
45
  - spec/integration/yard/**/*.rb
46
46
 
data/README.md CHANGED
@@ -13,11 +13,11 @@ This gem helps the creation of complex gems/concerns
13
13
  that enables creation of methods on the fly through class
14
14
  methods
15
15
 
16
- Next release: [1.10.0](https://github.com/darthjee/sinclair/compare/1.9.0...master)
16
+ Next release: [1.11.0](https://github.com/darthjee/sinclair/compare/1.10.0...master)
17
17
 
18
18
  Yard Documentation
19
19
  -------------------
20
- [https://www.rubydoc.info/gems/sinclair/1.9.0](https://www.rubydoc.info/gems/sinclair/1.9.0)
20
+ [https://www.rubydoc.info/gems/sinclair/1.10.0](https://www.rubydoc.info/gems/sinclair/1.10.0)
21
21
 
22
22
  Installation
23
23
  ---------------
data/config/yardstick.yml CHANGED
@@ -1,4 +1,4 @@
1
- threshold: 99.8
1
+ threshold: 100
2
2
  require_exact_threshold: false
3
3
  rules:
4
4
  ApiTag::Presence:
@@ -23,6 +23,10 @@ rules:
23
23
  - Sinclair::Options#==
24
24
  - Sinclair::OptionsParser#options
25
25
  - Sinclair::OptionsParser#options_object
26
+ - Sinclair::Matchers#add_method
27
+ - Sinclair::Matchers#add_class_method
28
+ - Sinclair::Matchers#change_method
29
+ - Sinclair::Matchers#change_class_method
26
30
  ReturnTag:
27
31
  enabled: true
28
32
  exclude:
@@ -50,7 +54,9 @@ rules:
50
54
  - Sinclair::Matchers::ChangeInstanceMethodOn#initialize
51
55
  - Sinclair::MethodBuilder
52
56
  - Sinclair::MethodBuilder::Base#initialize
57
+ - Sinclair::MethodBuilder::Accessor#initialize
53
58
  - Sinclair::MethodDefinition#initialize
59
+ - Sinclair::MethodDefinition::CallDefinition#initialize
54
60
  - Sinclair::MethodDefinition::BlockDefinition#initialize
55
61
  - Sinclair::MethodDefinition::StringDefinition#initialize
56
62
  - Sinclair::Options#initialize
@@ -81,6 +81,8 @@ class Sinclair
81
81
  # @method as_options(options_hash = {})
82
82
  # @api public
83
83
  #
84
+ # Returns options with configurated values
85
+ #
84
86
  # @param (see Sinclair::Config#as_options)
85
87
  # @return (see Sinclair::Config#as_options)
86
88
  # @example (see Sinclair::Config#as_options)
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'set'
4
+
3
5
  class Sinclair
4
6
  # @api public
5
7
  # @author darthjee
@@ -6,33 +6,33 @@ class Sinclair
6
6
  # @author darthjee
7
7
  #
8
8
  # AddClassMethod is able to build an instance of {Sinclair::Matchers::AddClassMethodTo}
9
- #
10
- # @example
11
- # RSpec.configure do |config|
12
- # config.include Sinclair::Matchers
13
- # end
14
- #
15
- # class MyModel
16
- # end
17
- #
18
- # RSpec.describe 'MyBuilder' do
19
- # let(:clazz) { Class.new(MyModel) }
20
- #
21
- # let(:block) do
22
- # proc do
23
- # clazz.define_singleton_method(:new_method) { 2 }
24
- # end
25
- # end
26
- #
27
- # it do
28
- # expect(&block).to add_class_method(:new_method).to(clazz)
29
- # end
30
- # end
31
- #
32
- # # outputs
33
- # # should add method class_method 'new_method' to #<Class:0x000055b4d0a25c80>
34
- class AddClassMethod < Base
35
- include AddMethod
9
+ class AddClassMethod < AddMethod
10
+ # @method #to(target = nil)
11
+ # @example Checking if a class had a class method added
12
+ # RSpec.configure do |config|
13
+ # config.include Sinclair::Matchers
14
+ # end
15
+ #
16
+ # class MyModel
17
+ # end
18
+ #
19
+ # RSpec.describe 'MyBuilder' do
20
+ # let(:clazz) { Class.new(MyModel) }
21
+ #
22
+ # let(:block) do
23
+ # proc do
24
+ # clazz.define_singleton_method(:new_method) { 2 }
25
+ # end
26
+ # end
27
+ #
28
+ # it do
29
+ # expect(&block).to add_class_method(:new_method).to(clazz)
30
+ # end
31
+ # end
32
+ #
33
+ # # outputs
34
+ # # should add method class_method 'new_method' to #<Class:0x000055b4d0a25c80>
35
+ with_final_matcher :to, AddClassMethodTo
36
36
 
37
37
  private
38
38
 
@@ -45,15 +45,6 @@ class Sinclair
45
45
  'You should specify which class the method is being added to' \
46
46
  "add_class_method(:#{method_name}).to(klass)"
47
47
  end
48
-
49
- # @private
50
- #
51
- # Class of the real matcher
52
- #
53
- # @return [Class<Sinclair::Matchers::Base>]
54
- def add_method_to_class
55
- AddClassMethodTo
56
- end
57
48
  end
58
49
  end
59
50
  end
@@ -7,56 +7,65 @@ class Sinclair
7
7
  #
8
8
  # AddInstanceMethod is able to build an instance of {Sinclair::Matchers::AddInstanceMethodTo}
9
9
  #
10
- # @example Using inside RSpec and checking Class
11
- # RSpec.configure do |config|
12
- # config.include Sinclair::Matchers
13
- # end
14
- #
15
- # class MyModel
16
- # end
17
- #
18
- # RSpec.describe "MyBuilder" do
19
- # let(:clazz) { Class.new(MyModel) }
20
- # let(:builder) { Sinclair.new(clazz) }
21
- #
22
- # before do
23
- # builder.add_method(:new_method, "2")
24
- # end
25
- #
26
- # it do
27
- # expect { builder.build }.to add_method(:new_method).to(clazz)
28
- # end
29
- # end
30
- #
31
- # # Outputs
32
- # # 'should add method 'new_method' to #<Class:0x000056441bf46608> instances'
33
- #
34
- # @example Using inside RSpec and checking instance
35
- # RSpec.configure do |config|
36
- # config.include Sinclair::Matchers
37
- # end
38
- #
39
- # class MyModel
40
- # end
41
- #
42
- # RSpec.describe "MyBuilder" do
43
- # let(:clazz) { Class.new(MyModel) }
44
- # let(:builder) { Sinclair.new(clazz) }
45
- # let(:instance) { clazz.new }
46
- #
47
- # before do
48
- # builder.add_method(:the_method, "true")
49
- # end
50
- #
51
- # it do
52
- # expect { builder.build }.to add_method(:the_method).to(instance)
53
- # end
54
- # end
55
- #
56
- # # Outputs
57
- # # 'should add method 'the_method' to #<Class:0x000056441bf46608> instances'
58
- class AddInstanceMethod < Base
59
- include AddMethod
10
+ class AddInstanceMethod < AddMethod
11
+ # @example Using inside RSpec and checking an instance method being added
12
+ # RSpec.configure do |config|
13
+ # config.include Sinclair::Matchers
14
+ # end
15
+ #
16
+ # class MyModel
17
+ # end
18
+ #
19
+ # RSpec.describe "MyBuilder" do
20
+ # let(:clazz) { Class.new(MyModel) }
21
+ # let(:builder) { Sinclair.new(clazz) }
22
+ #
23
+ # before do
24
+ # builder.add_method(:new_method, "2")
25
+ # end
26
+ #
27
+ # it do
28
+ # expect { builder.build }.to add_method(:new_method).to(clazz)
29
+ # end
30
+ # end
31
+ #
32
+ # # Outputs
33
+ # # 'should add method 'new_method' to #<Class:0x000056441bf46608> instances'
34
+ #
35
+ # @example Using inside RSpec and checking instance
36
+ # RSpec.configure do |config|
37
+ # config.include Sinclair::Matchers
38
+ # end
39
+ #
40
+ # class MyModel
41
+ # end
42
+ #
43
+ # RSpec.describe "MyBuilder" do
44
+ # let(:clazz) { Class.new(MyModel) }
45
+ # let(:builder) { Sinclair.new(clazz) }
46
+ # let(:instance) { clazz.new }
47
+ #
48
+ # before do
49
+ # builder.add_method(:the_method, "true")
50
+ # end
51
+ #
52
+ # it do
53
+ # expect { builder.build }.to add_method(:the_method).to(instance)
54
+ # end
55
+ # end
56
+ #
57
+ # # Outputs
58
+ # # 'should add method 'the_method' to #<Class:0x000056441bf46608> instances'
59
+ with_final_matcher :to, AddInstanceMethodTo
60
+
61
+ # @method to(target = nil)
62
+ # @api public
63
+ #
64
+ # The matcher checks if an instance method was added to a class
65
+ #
66
+ # @param (see AddMethod#to)
67
+ #
68
+ # @return [AddClassMethodTo]
60
69
 
61
70
  private
62
71
 
@@ -69,15 +78,6 @@ class Sinclair
69
78
  'You should specify which instance the method is being added to' \
70
79
  "add_method(:#{method_name}).to(instance)"
71
80
  end
72
-
73
- # @private
74
- #
75
- # Class of the real matcher
76
- #
77
- # @return [Class<Sinclair::Matchers::Base>]
78
- def add_method_to_class
79
- AddInstanceMethodTo
80
- end
81
81
  end
82
82
  end
83
83
  end
@@ -4,41 +4,39 @@ class Sinclair
4
4
  module Matchers
5
5
  # @api private
6
6
  #
7
- # Commone methods for matchers
8
- module AddMethod
9
- # @api public
10
- #
11
- # Builds final matcher
12
- #
13
- # The matcher checks if a method was added
14
- # to a class or instance
15
- #
16
- # @param [target] target where the method will be added
17
- #
18
- # @return [Sinclair::Matchers::Base]
19
- #
20
- # @example
21
- # RSpec.configure do |config|
22
- # config.include Sinclair::Matchers
23
- # end
24
- #
25
- # class MyModel
26
- # end
27
- #
28
- # RSpec.describe 'my test' do
29
- # let(:klass) { Class.new(MyModel) }
30
- # let(:builder) { Sinclair.new(klass) }
31
- #
32
- # before do
33
- # builder.add_method(:class_name, 'self.class.name')
34
- # end
35
- #
36
- # it do
37
- # expect { builder.build }.to add_method(:class_name).to(klass)
38
- # end
39
- # end
40
- def to(target = nil)
41
- add_method_to_class.new(target, method_name)
7
+ # Common methods for matchers
8
+ class AddMethod < Base
9
+ class << self
10
+ private
11
+
12
+ # @api private
13
+ # @private
14
+ #
15
+ # Add a method to generate the final matcher
16
+ #
17
+ # @param name [String,Symbol] the name of the method
18
+ # @param matcher_class [Class<AddMethodTo>] The matcher class to be returned
19
+ #
20
+ # @return (see Sinclair#build)
21
+ #
22
+ # @!macro with_final_matcher
23
+ # @!method $1(target = nil)
24
+ # @api public
25
+ #
26
+ # Builds final matcher
27
+ #
28
+ # The matcher checks if a method was added
29
+ # to a class or instance
30
+ #
31
+ # @param [Class,Object] target where the method will be added
32
+ #
33
+ # @return [$2]
34
+ def with_final_matcher(name, matcher_class)
35
+ matcher = matcher_class
36
+ Sinclair.new(self).tap do |builder|
37
+ builder.add_method(name) { |target| matcher.new(target, method_name) }
38
+ end.build
39
+ end
42
40
  end
43
41
 
44
42
  # @abstract
@@ -7,15 +7,30 @@ class Sinclair
7
7
  #
8
8
  # AddInstanceMethod is able to build an instance of
9
9
  # {Sinclair::Matchers::ChangeClassMethodOn}
10
- class ChangeClassMethod < Base
11
- include AddMethod
12
-
13
- # @api public
10
+ class ChangeClassMethod < AddMethod
11
+ # @example Checking if a class method has changed
12
+ # RSpec.configure do |config|
13
+ # config.include Sinclair::Matchers
14
+ # end
15
+ #
16
+ # class MyModel
17
+ # end
14
18
  #
15
- # Builds final matcher
19
+ # RSpec.describe 'my test' do
20
+ # let(:builder) { Sinclair.new(klass) }
21
+ # let(:klass) { Class.new(MyModel) }
16
22
  #
17
- # @return [Sinclair::Matchers::ChangeClassMethodOn]
18
- alias on to
23
+ # before do
24
+ # builder.add_class_method(:the_method) { 10 }
25
+ # builder.build
26
+ # builder.add_class_method(:the_method) { 20 }
27
+ # end
28
+ #
29
+ # it do
30
+ # expect{ builder.build }.to change_class_method(:the_method).on(klass)
31
+ # end
32
+ # end
33
+ with_final_matcher :on, ChangeClassMethodOn
19
34
 
20
35
  private
21
36
 
@@ -28,15 +43,6 @@ class Sinclair
28
43
  'You should specify which class the method is being changed on' \
29
44
  "change_class_method(:#{method_name}).on(klass)"
30
45
  end
31
-
32
- # @private
33
- #
34
- # Class of the real matcher
35
- #
36
- # @return [Class<ChangeClassMethodOn>]
37
- def add_method_to_class
38
- ChangeClassMethodOn
39
- end
40
46
  end
41
47
  end
42
48
  end
@@ -7,15 +7,54 @@ class Sinclair
7
7
  #
8
8
  # AddInstanceMethod is able to build an instance of
9
9
  # {Sinclair::Matchers::ChangeInstanceMethodOn}
10
- class ChangeInstanceMethod < Base
11
- include AddMethod
12
-
13
- # @api public
10
+ class ChangeInstanceMethod < AddMethod
11
+ # @example Checking if an instance method has changed
12
+ # RSpec.configure do |config|
13
+ # config.include Sinclair::Matchers
14
+ # end
15
+ #
16
+ # class MyModel
17
+ # end
18
+ #
19
+ # RSpec.describe 'my test' do
20
+ # let(:builder) { Sinclair.new(klass) }
21
+ # let(:klass) { Class.new(MyModel) }
22
+ #
23
+ # before do
24
+ # builder.add_method(:the_method) { 10 }
25
+ # builder.build
26
+ # builder.add_method(:the_method) { 20 }
27
+ # end
28
+ #
29
+ # it do
30
+ # expect{ builder.build }.to change_method(:the_method).on(klass)
31
+ # end
32
+ # end
33
+ #
34
+ # @example Checking if an instance method has changed on an instance
35
+ # RSpec.configure do |config|
36
+ # config.include Sinclair::Matchers
37
+ # end
38
+ #
39
+ # class MyModel
40
+ # end
14
41
  #
15
- # Builds final matcher
42
+ # RSpec.describe 'my test' do
43
+ # let(:builder) { Sinclair.new(klass) }
44
+ # let(:instance) { klass.new }
45
+ # let(:klass) { Class.new(MyModel) }
16
46
  #
17
- # @return [Sinclair::Matchers::ChangeInstanceMethodOn]
18
- alias on to
47
+ # before do
48
+ # builder.add_method(:the_method) { 10 }
49
+ # builder.build
50
+ # builder.add_method(:the_method) { 20 }
51
+ # end
52
+ #
53
+ # it do
54
+ # expect{ builder.build }.to change_method(:the_method).on(instance)
55
+ # end
56
+ # end
57
+ with_final_matcher :on, ChangeInstanceMethodOn
19
58
 
20
59
  private
21
60
 
@@ -28,15 +67,6 @@ class Sinclair
28
67
  'You should specify which instance the method is being changed on' \
29
68
  "change_method(:#{method_name}).on(instance)"
30
69
  end
31
-
32
- # @private
33
- #
34
- # Class of the real matcher
35
- #
36
- # @return [Class<Sinclair::Matchers::Base>]
37
- def add_method_to_class
38
- ChangeInstanceMethodOn
39
- end
40
70
  end
41
71
  end
42
72
  end
@@ -6,8 +6,6 @@ class Sinclair
6
6
  #
7
7
  # Matchers module will have the DSL to be included in RSpec in order to have
8
8
  # access to the matchers
9
- #
10
- # @example (see Sinclair::Matchers::AddMethod#to)
11
9
  module Matchers
12
10
  autoload :Base, 'sinclair/matchers/base'
13
11
  autoload :AddInstanceMethod, 'sinclair/matchers/add_instance_method'
@@ -25,7 +23,6 @@ class Sinclair
25
23
 
26
24
  # DSL to AddInstanceMethod
27
25
  #
28
- # @example (see Sinclair::Matchers)
29
26
  # @example (see Sinclair::Matchers::AddInstanceMethod#to)
30
27
  #
31
28
  # @return [AddInstanceMethod] RSpec Matcher
@@ -35,7 +32,6 @@ class Sinclair
35
32
 
36
33
  # DSL to AddClassMethod
37
34
  #
38
- # @example (see Sinclair::Matchers)
39
35
  # @example (see Sinclair::Matchers::AddClassMethod#to)
40
36
  #
41
37
  # @return [AddClassMethod] RSpec Matcher
@@ -45,8 +41,7 @@ class Sinclair
45
41
 
46
42
  # DSL to ChangeInstanceMethod
47
43
  #
48
- # @example (see Sinclair::Matchers)
49
- # @example (see Sinclair::Matchers::ChangeInstanceMethod#to)
44
+ # @example (see Sinclair::Matchers::ChangeInstanceMethod#on)
50
45
  #
51
46
  # @return [ChangeInstanceMethod] RSpec Matcher
52
47
  def change_method(method_name)
@@ -55,8 +50,7 @@ class Sinclair
55
50
 
56
51
  # DSL to ChangeClassMethod
57
52
  #
58
- # @example (see Sinclair::Matchers)
59
- # @example (see Sinclair::Matchers::ChangeClassMethod#to)
53
+ # @example (see Sinclair::Matchers::ChangeClassMethod#on)
60
54
  #
61
55
  # @return [ChangeClassMethod] RSpec Matcher
62
56
  def change_class_method(method_name)
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Sinclair
4
+ class MethodBuilder
5
+ # @api private
6
+ # @author darthjee
7
+ #
8
+ # Build a method based on a {MethodDefinition::CallDefinition}
9
+ class CallMethodBuilder < Base
10
+ # Builds the method
11
+ #
12
+ # @return [NilClass]
13
+ def build
14
+ klass.module_eval(code_line, __FILE__, __LINE__ + 1)
15
+ end
16
+
17
+ private
18
+
19
+ # @api private
20
+ # @private
21
+ #
22
+ # String to be evaluated when building the method
23
+ #
24
+ # This can be {code_string} or {class_code_string}
25
+ # @return (see MethodDefinition::CallDefinition#code_string)
26
+ def code_line
27
+ instance? ? code_string : class_code_string
28
+ end
29
+
30
+ delegate :code_string, :class_code_string, to: :definition
31
+
32
+ # @method code_string
33
+ # @private
34
+ # @api private
35
+ #
36
+ # Delegated from {MethodDefinition::CallDefinition}
37
+ #
38
+ # @see MethodDefinition::CallDefinition#code_string
39
+ # @return [String]
40
+
41
+ # @method class_code_string
42
+ # @private
43
+ # @api private
44
+ #
45
+ # @see MethodDefinition::CallDefinition#class_code_string
46
+ # @return [String]
47
+ end
48
+ end
49
+ end
@@ -9,6 +9,7 @@ class Sinclair
9
9
  autoload :Base, 'sinclair/method_builder/base'
10
10
  autoload :StringMethodBuilder, 'sinclair/method_builder/string_method_builder'
11
11
  autoload :BlockMethodBuilder, 'sinclair/method_builder/block_method_builder'
12
+ autoload :CallMethodBuilder, 'sinclair/method_builder/call_method_builder'
12
13
 
13
14
  CLASS_METHOD = :class
14
15
  INSTANCE_METHOD = :instance
@@ -53,8 +54,10 @@ class Sinclair
53
54
  def build_from_definition(definition, type)
54
55
  if definition.string?
55
56
  StringMethodBuilder.new(klass, definition, type: type).build
56
- else
57
+ elsif definition.block?
57
58
  BlockMethodBuilder.new(klass, definition, type: type).build
59
+ else
60
+ CallMethodBuilder.new(klass, definition, type: type).build
58
61
  end
59
62
  end
60
63
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Sinclair
4
+ class MethodDefinition
5
+ # @api private
6
+ # @author darthjee
7
+ #
8
+ # Define a call of method to e done within the class
9
+ class CallDefinition < MethodDefinition
10
+ # @param method_name [Symbol] method to be called
11
+ # @param arguments [Array<Symbol,String>] parameters to be passed as
12
+ # arguments to the call
13
+ def initialize(method_name, *arguments)
14
+ @arguments = arguments
15
+ super(method_name)
16
+ end
17
+
18
+ default_value :block?, false
19
+ default_value :string?, false
20
+
21
+ # String to be executed within the class
22
+ # @return [String]
23
+ def code_string
24
+ "#{name} :#{arguments.join(', :')}"
25
+ end
26
+
27
+ # String to be executed within the class running code to change the class itself
28
+ #
29
+ # @see code_string
30
+ # @return [String]
31
+ def class_code_string
32
+ <<-CODE
33
+ class << self
34
+ #{code_string}
35
+ end
36
+ CODE
37
+ end
38
+
39
+ private
40
+
41
+ attr_reader :arguments
42
+
43
+ # @method arguments
44
+ # @api private
45
+ # @private
46
+ #
47
+ # parameters to be passed as arguments to the call
48
+ #
49
+ # @return [Array<Symbol,String>]
50
+ end
51
+ end
52
+ end