-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Huge model "associations" and generator refactor
- Loading branch information
Showing
28 changed files
with
547 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/remote_generator/services/aggregate_model_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
module Foobara | ||
module RemoteGenerator | ||
class Services | ||
class AggregateModelGenerator < ModelGenerator | ||
class << self | ||
def new(relevant_manifest, elements_to_generate) | ||
return super unless self == AggregateModelGenerator | ||
|
||
if relevant_manifest.entity? | ||
AggregateEntityGenerator.new(relevant_manifest, elements_to_generate) | ||
elsif relevant_manifest.has_associations? | ||
super | ||
else | ||
ModelGenerator.new(relevant_manifest, elements_to_generate) | ||
end | ||
end | ||
end | ||
|
||
def target_path | ||
[*domain_path, "types", model_name, "Aggregate.ts"] | ||
end | ||
|
||
def template_path | ||
["Model", "Aggregate.ts.erb"] | ||
end | ||
|
||
def model_generators | ||
types_depended_on.select(&:model?).map do |model| | ||
if model.entity? | ||
Services::AggregateEntityGenerator.new(model, elements_to_generate) | ||
else | ||
Services::AggregateModelGenerator.new(model, elements_to_generate) | ||
end | ||
end | ||
end | ||
|
||
def attributes_type_ts_type | ||
aggregate_attributes_ts_type | ||
end | ||
|
||
def ts_instance_path | ||
*prefix, name = scoped_path | ||
[*prefix, "#{name}Aggregate"] | ||
end | ||
|
||
def ts_instance_full_path | ||
*prefix, name = scoped_full_path | ||
[*prefix, "#{name}Aggregate"] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module Foobara | ||
module RemoteGenerator | ||
class Services | ||
class AtomModelGenerator < ModelGenerator | ||
class << self | ||
def new(relevant_manifest, elements_to_generate) | ||
return super unless self == AtomModelGenerator | ||
|
||
if relevant_manifest.entity? | ||
AtomEntityGenerator.new(relevant_manifest, elements_to_generate) | ||
elsif relevant_manifest.has_associations? | ||
super | ||
else | ||
ModelGenerator.new(relevant_manifest, elements_to_generate) | ||
end | ||
end | ||
end | ||
|
||
def target_path | ||
[*domain_path, "types", model_name, "Atom.ts"] | ||
end | ||
|
||
def template_path | ||
["Model", "Atom.ts.erb"] | ||
end | ||
|
||
def model_generators | ||
types_depended_on.select(&:model?).map do |model| | ||
if model.entity? | ||
Services::UnloadedEntityGenerator.new(model, elements_to_generate) | ||
else | ||
Services::AtomModelGenerator.new(model, elements_to_generate) | ||
end | ||
end | ||
end | ||
|
||
def ts_instance_path | ||
*prefix, name = scoped_path | ||
[*prefix, "#{name}Atom"] | ||
end | ||
|
||
def ts_instance_full_path | ||
*prefix, name = scoped_full_path | ||
[*prefix, "#{name}Atom"] | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.