Module: Zuul::Generators::OrmHelpers

Instance Method Summary collapse

Instance Method Details

#migration_exists?(type, table_name) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/generators/zuul/orm_helpers.rb', line 8

def migration_exists?(type, table_name)
  Dir.glob("#{File.join(destination_root, migration_path)}/[0-9]*_*.rb").grep(/\d+_add_zuul_#{type.to_s}_to_#{table_name}.rb$/).first
end

#migration_pathObject



12
13
14
# File 'lib/generators/zuul/orm_helpers.rb', line 12

def migration_path
  @migration_path ||= File.join("db", "migrate")
end

#model_exists?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/generators/zuul/orm_helpers.rb', line 4

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

#model_pathObject



16
17
18
# File 'lib/generators/zuul/orm_helpers.rb', line 16

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