Class: BottledServiceGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/bottled_service/bottled_service_generator.rb

Instance Method Summary collapse

Instance Method Details

#generate_bottled_serviceObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/generators/bottled_service/bottled_service_generator.rb', line 6

def generate_bottled_service
  puts "Generating Bottled Service: #{name}"
  create_file "app/services/#{file_name}.rb", "class \#{class_name} < BottledService\n\n\#{ \"\".tap do |str|\n    attributes.each do |attribute|\n      puts \"injecting attribute: \#{attribute.name}\"\n      if attribute.type.present?\n        str << \"att :\#{attribute.name}, \#{attribute.type}\n\"\n      else\n        str << \"att :\#{attribute.name}\n\"\n      end\n    end\n  end\n}\n\ndef call\n  # Do something...\n  yield if block_given?\nend\n\nend\n  File\nend\n"