Class: Locomotive::Wagon::Generators::Relationship
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Locomotive::Wagon::Generators::Relationship
- Includes:
- CLI::ForceColor, Thor::Actions
- Defined in:
- lib/locomotive/wagon/generators/relationship.rb
Instance Method Summary collapse
Methods included from CLI::ForceColor
Instance Method Details
#content_types_must_exist ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/locomotive/wagon/generators/relationship.rb', line 19 def content_types_must_exist unless File.exists?(File.join(destination_root, source_path)) fail Thor::Error, "The #{source} content type does not exist" end unless File.exists?(File.join(destination_root, target_path)) fail Thor::Error, "The #{target} content type does not exist" end end |
#modify_content_types ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/locomotive/wagon/generators/relationship.rb', line 29 def modify_content_types case type.to_sym when :belongs_to append_to_file source_path, build_belongs_to_field(source, target) append_to_file target_path, build_has_many_field(target, source) when :has_many append_to_file source_path, build_has_many_field(source, target) append_to_file target_path, build_belongs_to_field(target, source) when :many_to_many append_to_file source_path, build_many_to_many_field(source, target) append_to_file target_path, build_many_to_many_field(target, source) else fail Thor::Error, "#{type} is an unknown relationship type" end end |