Module: Roomer::Helpers::GeneratorHelper

Included in:
Generators::MigrationGenerator, Generators::ModelGenerator
Defined in:
lib/roomer/helpers/generator_helper.rb

Instance Method Summary collapse

Instance Method Details

#migration_dirObject

Fetchs the migration directory for the migrations



24
25
26
27
# File 'lib/roomer/helpers/generator_helper.rb', line 24

def migration_dir
  return Roomer.shared_migrations_directory if shared?
  return Roomer.tenanted_migrations_directory
end

#model_exists?True, False

Check to see if the model file exists, should be used in a Generator

Returns:

  • (True, False)


7
8
9
# File 'lib/roomer/helpers/generator_helper.rb', line 7

def model_exists?
  File.exists?(File.join(destination_root, model_path))
end

#model_pathString

Returns the path of the model

Returns:

  • (String)

    model_path string representing the model location



13
14
15
# File 'lib/roomer/helpers/generator_helper.rb', line 13

def model_path
  @model_path ||= File.join("app", "models", "#{file_path}.rb")
end

#shared?True, False

Reads the –shared option specified when running “rails generate roomer:model”

Returns:

  • (True, False)


19
20
21
# File 'lib/roomer/helpers/generator_helper.rb', line 19

def shared?
  @shared ||= options[:shared]
end