Class: TrailblazerWizard::ConceptGenerator
- Inherits:
-
Object
- Object
- TrailblazerWizard::ConceptGenerator
- Defined in:
- lib/trailblazer_wizard/concept_generator.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #generate(model, name, context = nil) ⇒ Object
-
#initialize(**args) ⇒ ConceptGenerator
constructor
A new instance of ConceptGenerator.
- #true_type ⇒ Object
- #type_dirname ⇒ Object
Constructor Details
#initialize(**args) ⇒ ConceptGenerator
Returns a new instance of ConceptGenerator.
9 10 11 |
# File 'lib/trailblazer_wizard/concept_generator.rb', line 9 def initialize(**args)\ @type = args[:type] end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/trailblazer_wizard/concept_generator.rb', line 7 def type @type end |
Instance Method Details
#generate(model, name, context = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/trailblazer_wizard/concept_generator.rb', line 17 def generate(model, name, context = nil) materials = [model, type_dirname, name] materials.insert(1, context) unless context.nil? filename = materials.map { |material| ActiveSupport::Inflector.underscore(material) }.join("/") filename = "#{TrailblazerWizard.configuration.base_directory}/#{filename}.rb" false if File.exist?(filename) content = copy(model, name, context) create_file(filename, content) filename end |
#true_type ⇒ Object
13 |
# File 'lib/trailblazer_wizard/concept_generator.rb', line 13 def true_type = (TrailblazerWizard.configuration.alt_types[type.to_sym] || type).to_s |
#type_dirname ⇒ Object
15 |
# File 'lib/trailblazer_wizard/concept_generator.rb', line 15 def type_dirname = TrailblazerWizard.configuration.pluralize ? ActiveSupport::Inflector.pluralize(true_type) : true_type |