Module: Hanami::Generators::Generatable

Included in:
Commands::Generate::Abstract, Commands::New::Abstract
Defined in:
lib/hanami/generators/generatable.rb

Instance Method Summary collapse

Instance Method Details

#add_mapping(source, target) ⇒ Object


25
26
27
# File 'lib/hanami/generators/generatable.rb', line 25

def add_mapping(source, target)
  generator.add_mapping(source, target)
end

#argument_blank?(value) ⇒ Boolean

Returns:

  • (Boolean)

50
51
52
# File 'lib/hanami/generators/generatable.rb', line 50

def argument_blank?(value)
  Hanami::Utils::Blank.blank?(value)
end

#destroyObject


12
13
14
15
# File 'lib/hanami/generators/generatable.rb', line 12

def destroy
  generator.behavior = :revoke
  self
end

#generatorObject


17
18
19
# File 'lib/hanami/generators/generatable.rb', line 17

def generator
  @generator ||= Hanami::Generators::Generator.new(template_source_path, target_path)
end

#map_templatesObject

Raises:

  • (NotImplementedError)

21
22
23
# File 'lib/hanami/generators/generatable.rb', line 21

def map_templates
  raise NotImplementedError, "must implement the map_templates method"
end

#post_process_templatesObject


34
35
36
# File 'lib/hanami/generators/generatable.rb', line 34

def post_process_templates
  nil
end

#process_templatesObject


29
30
31
32
# File 'lib/hanami/generators/generatable.rb', line 29

def process_templates
  generator.process_templates(template_options)
  post_process_templates
end

#startObject


7
8
9
10
# File 'lib/hanami/generators/generatable.rb', line 7

def start
  map_templates
  process_templates
end

#target_pathObject

Raises:

  • (NotImplementedError)

46
47
48
# File 'lib/hanami/generators/generatable.rb', line 46

def target_path
  raise NotImplementedError, "must implement the target_path method"
end

#template_optionsObject


38
39
40
# File 'lib/hanami/generators/generatable.rb', line 38

def template_options
  {}
end

#template_source_pathObject

Raises:

  • (NotImplementedError)

42
43
44
# File 'lib/hanami/generators/generatable.rb', line 42

def template_source_path
  raise NotImplementedError, "must implement the template_source_path method"
end