hecks-domain 0.1.0 → 0.1.2.rc

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +5 -5
  2. data/lib/adapters/adapters.rb +2 -0
  3. data/lib/adapters/resource_server/cli/cli.rb +1 -0
  4. data/lib/adapters/resource_server/cli/generate_resource_server.rb +25 -0
  5. data/lib/adapters/resource_server/cli/templates/resource_server/config.ru.tt +8 -0
  6. data/lib/adapters/resource_server/resource_server.rb +3 -0
  7. data/lib/adapters/sql_database/cli/cli.rb +3 -0
  8. data/lib/adapters/sql_database/cli/generate_domain_migrations.rb +33 -0
  9. data/lib/adapters/sql_database/cli/generate_sql_database.rb +35 -0
  10. data/lib/adapters/sql_database/cli/migration_builder.rb +51 -0
  11. data/lib/adapters/sql_database/cli/templates/migration.rb.tt +14 -0
  12. data/lib/adapters/sql_database/cli/templates/repository.rb.tt +24 -0
  13. data/lib/adapters/sql_database/cli/templates/sql_database/Rakefile +15 -0
  14. data/lib/adapters/sql_database/commands/read/fetch_references.rb +58 -0
  15. data/lib/adapters/sql_database/commands/update/delete_references.rb +45 -0
  16. data/lib/adapters/sql_database/commands/update/link_to_references.rb +45 -0
  17. data/lib/adapters/sql_database/sql_database.rb +1 -0
  18. data/lib/cli/builder/aggregate_command_line_builder.rb +22 -0
  19. data/lib/cli/builder/builder.rb +3 -0
  20. data/lib/cli/builder/reference_command_line_builder.rb +23 -0
  21. data/lib/cli/builder/value_object_command_line_builder.rb +23 -0
  22. data/lib/cli/cli.rb +8 -0
  23. data/lib/cli/command_builder.rb +60 -0
  24. data/lib/cli/domain_object/assignment_template.rb +43 -0
  25. data/lib/cli/domain_object/option_formatter.rb +36 -0
  26. data/lib/cli/generate_domain_object.rb +71 -0
  27. data/lib/cli/new.rb +50 -0
  28. data/lib/cli/templates/aggregate/lib/domain/%name%/%head_name%.rb.tt +16 -0
  29. data/lib/cli/templates/aggregate/lib/domain/%name%/%name%.rb.tt +9 -0
  30. data/lib/cli/templates/aggregate/lib/domain/%name%/repository.rb.tt +41 -0
  31. data/lib/cli/templates/domain/%name%.gemspec.tt +12 -0
  32. data/lib/cli/templates/domain/Version +1 -0
  33. data/lib/cli/templates/domain/lib/%name%.rb.tt +21 -0
  34. data/lib/cli/templates/domain/spec/spec_helper.rb.tt +4 -0
  35. data/lib/cli/templates/reference/lib/domain/%module_name%/%file_name%.rb.tt +25 -0
  36. data/lib/cli/templates/value_object/lib/domain/%module_name%/%name%.rb.tt +24 -0
  37. data/lib/domain_builder/attribute.rb +60 -0
  38. data/lib/domain_builder/domain.rb +19 -0
  39. data/lib/domain_builder/domain_builder.rb +37 -0
  40. data/lib/domain_builder/domain_module.rb +28 -0
  41. data/lib/domain_builder/domain_object.rb +43 -0
  42. data/lib/domain_builder/head.rb +8 -0
  43. data/lib/domain_builder/reference.rb +19 -0
  44. data/lib/domain_builder/value.rb +8 -0
  45. data/lib/hecks-domain.rb +6 -0
  46. metadata +58 -101
  47. data/lib/hecks/domain/commands/generate.rb +0 -98
  48. data/lib/hecks/domain/commands.rb +0 -1
  49. data/lib/hecks/domain/generators/domain.rb +0 -21
  50. data/lib/hecks/domain/generators/domain_files.rb +0 -28
  51. data/lib/hecks/domain/generators/entity.rb +0 -30
  52. data/lib/hecks/domain/generators/operation.rb +0 -32
  53. data/lib/hecks/domain/generators/root.rb +0 -30
  54. data/lib/hecks/domain/generators/spec.rb +0 -30
  55. data/lib/hecks/domain/generators/value_object.rb +0 -30
  56. data/lib/hecks/domain/generators.rb +0 -7
  57. data/lib/hecks/domain/parser/aggregate.rb +0 -44
  58. data/lib/hecks/domain/parser/domain_object.rb +0 -123
  59. data/lib/hecks/domain/parser/entity_field.rb +0 -55
  60. data/lib/hecks/domain/parser/fields.rb +0 -16
  61. data/lib/hecks/domain/parser/list_field.rb +0 -13
  62. data/lib/hecks/domain/parser/operation.rb +0 -15
  63. data/lib/hecks/domain/parser/reference_field.rb +0 -12
  64. data/lib/hecks/domain/parser/spec_helper.rb +0 -0
  65. data/lib/hecks/domain/parser/value_field.rb +0 -48
  66. data/lib/hecks/domain/parser.rb +0 -95
  67. data/lib/hecks/domain/support/string.rb +0 -9
  68. data/lib/hecks/domain/support.rb +0 -1
  69. data/lib/hecks/domain/templates/%domain_name%.gemspec.tt +0 -12
  70. data/lib/hecks/domain/templates/%folder_name%/Domainfile.tt +0 -9
  71. data/lib/hecks/domain/templates/%folder_name%/events/command_will_run.rb.tt +0 -11
  72. data/lib/hecks/domain/templates/%folder_name%/spec/spec_helper.rb.tt +0 -1
  73. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/commands.rb.tt +0 -11
  74. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/events.rb.tt +0 -11
  75. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/factories/build.rb.tt +0 -37
  76. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/factories.rb.tt +0 -11
  77. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/invariants.rb.tt +0 -11
  78. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/queries.rb.tt +0 -11
  79. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/repository.rb.tt +0 -68
  80. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%/subscribers.rb.tt +0 -11
  81. data/lib/hecks/domain/templates/entity/%aggregate_name%/%domain_object_name%.rb.tt +0 -34
  82. data/lib/hecks/domain/templates/lib/%domain_name%.rb.tt +0 -9
  83. data/lib/hecks/domain/templates/lib/support/commands/command_loader.rb +0 -18
  84. data/lib/hecks/domain/templates/lib/support/commands/command_runner.rb +0 -17
  85. data/lib/hecks/domain/templates/lib/support/commands.rb +0 -2
  86. data/lib/hecks/domain/templates/lib/support/domain_object.rb +0 -25
  87. data/lib/hecks/domain/templates/lib/support/events/domain_event.rb +0 -14
  88. data/lib/hecks/domain/templates/lib/support/events/domain_event_publisher.rb +0 -34
  89. data/lib/hecks/domain/templates/lib/support/events.rb +0 -14
  90. data/lib/hecks/domain/templates/lib/support/factories/factory_loader.rb +0 -21
  91. data/lib/hecks/domain/templates/lib/support/factories.rb +0 -1
  92. data/lib/hecks/domain/templates/lib/support/invariants/invariant_loader.rb +0 -24
  93. data/lib/hecks/domain/templates/lib/support/queries/query_loader.rb +0 -18
  94. data/lib/hecks/domain/templates/lib/support/queries.rb +0 -1
  95. data/lib/hecks/domain/templates/lib/support/repositories/repository_loader.rb +0 -32
  96. data/lib/hecks/domain/templates/lib/support/root.rb +0 -27
  97. data/lib/hecks/domain/templates/lib/support/support/string.rb +0 -9
  98. data/lib/hecks/domain/templates/lib/support.rb +0 -11
  99. data/lib/hecks/domain/templates/operation/%aggregate_name%/%domain_object_name%/commands/%operation_name%.rb.tt +0 -21
  100. data/lib/hecks/domain/templates/root/%aggregate_name%/root.rb.tt +0 -14
  101. data/lib/hecks/domain/templates/spec/%aggregate_name%/%root_name%_spec.rb.tt +0 -12
  102. data/lib/hecks/domain/templates/value_object/%aggregate_name%/%domain_object_name%/factories/build.rb.tt +0 -37
  103. data/lib/hecks/domain/templates/value_object/%aggregate_name%/%domain_object_name%/factories.rb.tt +0 -11
  104. data/lib/hecks/domain/templates/value_object/%aggregate_name%/%domain_object_name%.rb.tt +0 -34
  105. data/lib/hecks/domain/top_level_methods.rb +0 -3
  106. data/lib/hecks/domain.rb +0 -22
@@ -1,123 +0,0 @@
1
- class HecksDomain
2
- class Parser
3
- class DomainObject
4
- attr_reader :name, :aggregate, :fields
5
-
6
- def initialize(name, aggregate, &block)
7
- @name = name
8
- @aggregate = aggregate
9
- @operations = []
10
- @fields = []
11
- if is_a?(Entity)
12
- add_field(:id, IntegerField).tap { |field| field.optional = true }
13
- end
14
- instance_eval(&block)
15
- end
16
-
17
- def optional(value)
18
- value.optional = true
19
- end
20
-
21
- def initializer_attributes
22
- @fields.reject(&:read_only?).map(&:attribute_name).join(', ')
23
- end
24
-
25
- def invariants
26
- @invariants
27
- end
28
-
29
- def boolean_accessors
30
- @fields.select { |field| field.is_a?(BooleanField) }
31
- end
32
-
33
- def list_accessors
34
- @fields.select { |field| field.is_a?(ListField) }
35
- end
36
-
37
- def public_accessors
38
- @fields.map do |field|
39
- field.public_accessor
40
- end.tap do |fields|
41
- fields << ':id' if is_a?(Entity)
42
- end.compact.join(', ')
43
- end
44
-
45
- def private_accessors
46
- @fields.map do |field|
47
- field.private_accessor
48
- end.compact.join(', ')
49
- end
50
-
51
- def commands
52
- @commands
53
- end
54
-
55
- def list(name)
56
- add_field(name, ListField)
57
- end
58
-
59
- def string(name)
60
- add_field(name, StringField)
61
- end
62
-
63
- def integer(name)
64
- add_field(name, IntegerField)
65
- end
66
-
67
- def operations(list)
68
- @operations = list
69
-
70
- @operations = list.map do |name|
71
- Operation.new(name: name, domain_object: self)
72
- end
73
- end
74
-
75
- def operations_get
76
- @operations
77
- end
78
-
79
- def currency(name)
80
- add_field(name, CurrencyField)
81
- end
82
-
83
- def value(name)
84
- add_field(name, ValueField)
85
- end
86
-
87
- def boolean(name)
88
- add_field(name, BooleanField)
89
- end
90
-
91
- def entity(name)
92
- add_field(name, EntityField)
93
- end
94
-
95
- def reference(name)
96
- add_field(name, ReferenceField)
97
- end
98
-
99
- def file_name
100
- folder_name + '.rb'
101
- end
102
-
103
- def folder_name
104
- @name.to_s.underscore
105
- end
106
-
107
- def read_only(value)
108
- value.read_only = true
109
- value
110
- end
111
-
112
- def binding
113
- super
114
- end
115
-
116
- private
117
-
118
- def add_field(name, type)
119
- type.new(name).tap { |field| @fields << field }
120
- end
121
- end
122
- end
123
- end
@@ -1,55 +0,0 @@
1
- class HecksDomain
2
- class Parser
3
- class EntityField
4
- attr_reader :name
5
-
6
- def initialize(name)
7
- @name = name
8
- end
9
-
10
- def as(name)
11
- @as = name
12
- self
13
- end
14
-
15
- def module_name
16
- @as
17
- end
18
-
19
- def public_accessor
20
- ":#{name}"
21
- end
22
-
23
- def private_accessor
24
- ":#{name}"
25
- end
26
-
27
- def initial_state
28
- name
29
- end
30
-
31
- def read_only=(value)
32
- @read_only = value
33
- end
34
-
35
- def optional=(value)
36
- @optional = value
37
- end
38
-
39
- def read_only?
40
- @read_only
41
- end
42
-
43
- def optional?
44
- @optional
45
- end
46
-
47
- def attribute_name
48
- return name.to_s + ':' unless optional?
49
- return name.to_s + ': []' if is_a?(ListField)
50
-
51
- name.to_s + ': nil'
52
- end
53
- end
54
- end
55
- end
@@ -1,16 +0,0 @@
1
- class HecksDomain
2
- class Parser
3
- class BooleanField < ValueField
4
- def initial_state
5
- return 'nil' if read_only?
6
- name
7
- end
8
- end
9
- class Entity < DomainObject;end
10
- class Root < Entity;end
11
- class ValueObject < DomainObject;end
12
- class StringField < ValueField;end
13
- class IntegerField < ValueField;end
14
- class CurrencyField < ValueField;end
15
- end
16
- end
@@ -1,13 +0,0 @@
1
- class HecksDomain
2
- class Parser
3
- class ListField < EntityField
4
- def initial_state
5
- return '[]' if read_only?
6
-
7
- name
8
- end
9
-
10
- def public_accessor; end
11
- end
12
- end
13
- end
@@ -1,15 +0,0 @@
1
- class HecksDomain
2
- class Parser
3
- class Operation
4
- attr_reader :name
5
- def initialize(name:, domain_object:)
6
- @name = name
7
- @domain_object = domain_object
8
- end
9
-
10
- def binding
11
- super
12
- end
13
- end
14
- end
15
- end
@@ -1,12 +0,0 @@
1
- class HecksDomain
2
- class Parser
3
- class ReferenceField
4
- class ReferenceField < EntityField
5
- attr_reader :name
6
- def module_name
7
- @as.keys.first.to_s + '::' + @as.values.first.to_s
8
- end
9
- end
10
- end
11
- end
12
- end
File without changes
@@ -1,48 +0,0 @@
1
- class HecksDomain
2
- class Parser
3
- class ValueField
4
- attr_reader :name
5
- attr_writer :optional
6
- attr_writer :read_only
7
-
8
- def initialize(name)
9
- @name = name
10
- end
11
-
12
- def optional?
13
- @optional
14
- end
15
-
16
- def initial_state
17
- name
18
- end
19
-
20
- def attribute_name
21
- return name.to_s + ':' unless optional?
22
-
23
- name.to_s + ': nil'
24
- end
25
-
26
- def public_accessor
27
- ":#{name}"
28
- end
29
-
30
- def private_accessor
31
- ":#{name}"
32
- end
33
-
34
- def module_name
35
- @as
36
- end
37
-
38
- def read_only?
39
- @read_only
40
- end
41
-
42
- def as(name)
43
- @as = name
44
- self
45
- end
46
- end
47
- end
48
- end
@@ -1,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'parser/aggregate'
4
- require_relative 'parser/domain_object'
5
- require_relative 'parser/value_field'
6
- require_relative 'parser/entity_field'
7
- require_relative 'parser/list_field'
8
- require_relative 'parser/operation'
9
- require_relative 'parser/reference_field'
10
- require_relative 'parser/fields'
11
-
12
- class HecksDomain
13
- class Parser
14
- attr_reader :name, :aggregates, :spec_helper, :string_support,
15
- :repository_helper, :factory_loader
16
-
17
- def initialize(name, &block)
18
- @name = name
19
- @aggregates = []
20
- @domain_version = nil
21
- instance_eval(&block)
22
- end
23
-
24
- def summary(value)
25
- @summary = value
26
- end
27
-
28
- def description(value)
29
- @description = value
30
- end
31
-
32
- def version(value)
33
- @version = value
34
- end
35
-
36
- def gemspec
37
- {
38
- summary: @summary,
39
- description: @description,
40
- version: @version,
41
- authors: @authors,
42
- email: @email,
43
- homepage: @homepage
44
- }
45
- end
46
-
47
- def authors(value)
48
- @authors = value
49
- end
50
-
51
- def email(value)
52
- @email = value
53
- end
54
-
55
- def homepage(value)
56
- @homepage = value
57
- end
58
-
59
- def aggregate(name, &block)
60
- @aggregates << Aggregate.new(name, self, &block)
61
- end
62
-
63
- def binding
64
- super
65
- end
66
-
67
- def file_name
68
- @file_name = folder_name + '.rb'
69
- end
70
-
71
- def folder_name
72
- @folder_name = @name.to_s.underscore
73
- end
74
-
75
- def domain_version(value)
76
- @domain_version = value
77
- end
78
-
79
- def for_each_domain_object
80
- aggregates.each do |aggregate|
81
- aggregate.domain_objects.each do |domain_object|
82
- yield aggregate, domain_object
83
- end
84
- end
85
- end
86
-
87
- def for_each_operation
88
- for_each_domain_object do |aggregate, domain_object|
89
- domain_object.operations_get.each do |operation|
90
- yield aggregate, domain_object, operation
91
- end
92
- end
93
- end
94
- end
95
- end
@@ -1,9 +0,0 @@
1
- class String
2
- def underscore
3
- self.gsub(/::/, '/').
4
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
5
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
6
- tr("-", "_").
7
- downcase
8
- end
9
- end
@@ -1 +0,0 @@
1
- require_relative 'support/string'
@@ -1,12 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.name = '<%= domain_name %>'
3
- s.version = '<%= gemspec[:version] %>'
4
- s.licenses = ['MIT']
5
- s.summary = '<%= gemspec[:summary] %>'
6
- s.description = '<%= gemspec[:description] %>'
7
- s.authors = <%= gemspec[:authors] %>
8
- s.email = '<%= gemspec[:email] %>'
9
- s.files = Dir['lib/**/*.rb', 'domain/**/*.rb', 'events/**/*.rb', 'Domainfile']
10
- s.homepage = '<%= gemspec[:homepage] %>'
11
- s.metadata = { 'hecks_domain' => 'true' }
12
- end
@@ -1,9 +0,0 @@
1
- domain(:<%= domain_name %>) do
2
- summary '<FILL ME IN>'
3
- description '<FILL ME IN>'
4
- version '0.0.1'
5
- authors ['<FILL ME IN>']
6
- email '<FILL ME IN>'
7
- homepage 'http://www.example.com'
8
- domain_version '0.1.0'
9
- end
@@ -1,11 +0,0 @@
1
- module <%= domain_name %>
2
- module Events
3
- class CommandWillRun
4
- attr_reader :root, :args, :command_to_run
5
- def initialize(command)
6
- @root = command.root
7
- @command_to_run = command
8
- end
9
- end
10
- end
11
- end
@@ -1 +0,0 @@
1
- require_relative '../lib/<%= domain_name.underscore %>'
@@ -1,11 +0,0 @@
1
- Dir[File.dirname(__FILE__) + '/commands/*.rb'].each {|file| require_relative file }
2
- module <%= @domain.name %>
3
- module Domain
4
- module <%= @aggregate.name %>
5
- class <%= @domain_object.name %>
6
- module Commands
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- Dir[File.dirname(__FILE__) + '/events/*.rb'].each { |file| require_relative file }
2
- module <%= domain.name %>
3
- module Domain
4
- module <%= aggregate.name %>
5
- class <%= domain_object.name %>
6
- module Events
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,37 +0,0 @@
1
- module <%= @domain.name %>
2
- module Domain
3
- module <%= @aggregate.name%>
4
- class <%= @domain_object.name %>
5
- module Factories
6
- # Recursively build domain objects. Used in the domain as the primary
7
- # factory. The results of #build can be passed to any other build
8
- # factory in the domain. Takes a hash, or a list of hashes. If a list
9
- # is given, it will return a list of the instantiated objects
10
- class Build
11
- def self.factory(args=nil)
12
- return args if args.nil?
13
- return args unless args.is_a?(Hash)
14
-
15
- [args].flatten.map do |domain_object_args|
16
- new_domain_object(domain_object_args)
17
- end.tap do |result|
18
- return result.first unless args.is_a?(Array)
19
- end
20
- end
21
-
22
- def self.new_domain_object(args)
23
- <%= @domain_object.name %>.new(
24
- args.merge(
25
- <% @domain_object.fields.each do |field| -%>
26
- <% next unless (field.respond_to?(:module_name) && field.module_name) -%>
27
- <%= field.name.to_s%>: <%= field.module_name.is_a?(Hash) ? 'Domain::' + field.module_name.to_a.join('::').to_s : field.module_name.to_s %>.build(args[:<%= field.name.to_s%>]<%= ' || []' if field.is_a?(HecksDomain::Parser::ListField) %>),
28
- <% end -%>
29
- )
30
- )
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,11 +0,0 @@
1
- Dir[File.dirname(__FILE__) + '/factories/*.rb'].each {|file| require_relative file }
2
- module <%= domain.name %>
3
- module Domain
4
- module <%= aggregate.name %>
5
- class <%= domain_object.name %>
6
- module Factories
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- Dir[File.dirname(__FILE__) + '/invariants/*.rb'].each {|file| require_relative file }
2
- module <%= domain.name %>
3
- module Domain
4
- module <%= aggregate.name %>
5
- class <%= domain_object.name %>
6
- module Invariants
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- Dir[File.dirname(__FILE__) + '/queries/*.rb'].each { |file| require_relative file }
2
- module <%= domain.name %>
3
- module Domain
4
- module <%= aggregate.name %>
5
- class <%= domain_object.name %>
6
- module Queries
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,68 +0,0 @@
1
-
2
- module <%= domain.name %>
3
- module Domain
4
- module <%= aggregate.name %>
5
- class <%= domain_object.name %>
6
- class Repository
7
- include Singleton
8
- def self.save(object)
9
- instance.save(object)
10
- end
11
-
12
- def self.fetch(<%= domain_object_name %>)
13
- instance.fetch(<%= domain_object_name %>)
14
- end
15
-
16
- def initialize
17
- @objects = {}
18
- end
19
-
20
- def self.create(<%= domain_object_name %>)
21
- instance.create(<%= domain_object_name %>)
22
- end
23
-
24
- def self.all
25
- instance.all
26
- end
27
-
28
- def self.destroy(<%= domain_object_name %>)
29
- instance.destroy(<%= domain_object_name %>)
30
- end
31
-
32
- def all
33
- @objects.values
34
- end
35
-
36
- def destroy(<%= domain_object_name %>)
37
- @objects.delete(<%= domain_object_name %>.id)
38
- end
39
-
40
- def create(<%= domain_object_name %>)
41
- klass = self.class.const_get(
42
- self.class.to_s.gsub('::Repository', '')
43
- )
44
- domain_object = klass.build(<%= domain_object_name %>)
45
- domain_object.tap(&:save)
46
- end
47
-
48
- def fetch(fetchable)
49
- return @objects[fetchable.id] if fetchable.respond_to?(:id)
50
-
51
- @objects[fetchable]
52
- end
53
-
54
- def save(<%= domain_object_name %>)
55
- domain_object = <%= domain_object_name %>
56
- @objects[<%= domain_object_name %>.hash] = domain_object
57
-
58
- <%= domain_object_name %>.instance_eval do
59
- @id = <%= domain_object_name %>.hash
60
- end
61
-
62
- <%= domain_object_name %>
63
- end
64
- end
65
- end
66
- end
67
- end
68
- end
@@ -1,11 +0,0 @@
1
- Dir[File.dirname(__FILE__) + '/subscribers/*.rb'].each { |file| require_relative file }
2
- module <%= @domain.name %>
3
- module Domain
4
- module <%= aggregate.name %>
5
- class <%= domain_object.name %>
6
- module Subscribers
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,34 +0,0 @@
1
- module <%= domain.name %>
2
- module Domain
3
- module <%= aggregate.name %>
4
- class <%= domain_object.name %>
5
- <%= 'include Support::Root' if domain_object.is_a?(HecksDomain::Parser::Root) %>
6
- include Support::DomainObject
7
-
8
- attr_reader <%= domain_object.public_accessors %>
9
-
10
- def initialize(<%= domain_object.initializer_attributes %>)
11
- <% domain_object.fields.each do |field| -%>
12
- <%= "@#{field.name} = #{field.initial_state}" %>
13
- <% end -%>
14
- end
15
- <% domain_object.boolean_accessors.each do |field| -%>
16
-
17
- def <%= field.name %>?
18
- @<%= field.name %>
19
- end
20
- <% end -%>
21
- <% domain_object.list_accessors.each do |field| -%>
22
-
23
- def <%= field.name %>
24
- @<%= field.name %>.clone.freeze
25
- end
26
- <% end -%>
27
-
28
- private
29
-
30
- attr_writer <%= domain_object.private_accessors %>
31
- end
32
- end
33
- end
34
- end
@@ -1,9 +0,0 @@
1
- require_relative 'support'
2
- Dir[File.dirname(__FILE__) + "/../events/*.rb"].each { |file| require_relative file }
3
- <% domain.aggregates.each do |aggregate| -%>
4
- require_relative '../domain/<%= aggregate.folder_name %>/root'
5
- <% end -%>
6
-
7
- module <%= domain.name %>
8
- class InvariantViolationError < StandardError; end
9
- end
@@ -1,18 +0,0 @@
1
- class Support
2
- module Commands
3
- module CommandLoader
4
- def self.included(base)
5
- return unless base.constants.include?(:Commands)
6
- base::Commands.constants.each do |constant|
7
- base.class_eval "
8
- def #{constant.to_s.underscore}!(*args, &block)
9
- Support::Commands::CommandRunner.run(
10
- Commands::#{constant}.new(self, *args), &block
11
- )
12
- end
13
- "
14
- end
15
- end
16
- end
17
- end
18
- end