Class: Mongify::Mongoid::CLI::Command::Worker
- Inherits:
-
Object
- Object
- Mongify::Mongoid::CLI::Command::Worker
- Defined in:
- lib/mongify/mongoid/cli/command/worker.rb
Overview
A command to run the different commands in the application (related to Mongifying).
Instance Attribute Summary collapse
-
#view ⇒ Object
Returns the value of attribute view.
Instance Method Summary collapse
-
#execute(view) ⇒ Object
Executes the worked based on a given command.
-
#initialize(translation_file = nil, output_dir = nil, options = {}) ⇒ Worker
constructor
A new instance of Worker.
-
#output_folder ⇒ Object
Folder location of the output.
Constructor Details
#initialize(translation_file = nil, output_dir = nil, options = {}) ⇒ Worker
Returns a new instance of Worker.
12 13 14 15 16 |
# File 'lib/mongify/mongoid/cli/command/worker.rb', line 12 def initialize(translation_file=nil, output_dir=nil, ={}) @translation_file = translation_file @output_dir = output_dir @options = end |
Instance Attribute Details
#view ⇒ Object
Returns the value of attribute view.
9 10 11 |
# File 'lib/mongify/mongoid/cli/command/worker.rb', line 9 def view @view end |
Instance Method Details
#execute(view) ⇒ Object
Executes the worked based on a given command
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mongify/mongoid/cli/command/worker.rb', line 19 def execute(view) self.view = view valid_translation? @translation_file prevent_overwrite! (@options) unless File.directory?(output_folder) FileUtils.mkdir_p(output_folder) end @generator = Mongify::Mongoid::Generator.new(@translation_file, output_folder) @generator.process view.report_success end |
#output_folder ⇒ Object
Folder location of the output
38 39 40 41 |
# File 'lib/mongify/mongoid/cli/command/worker.rb', line 38 def output_folder @output_dir = File.join(Dir.pwd, "models") if @output_dir.nil? @output_dir end |