Module: Zuul::Generators::OrmHelpers
- Included in:
- ActiveRecord::Zuul::Generators::PermissionGenerator, ActiveRecord::Zuul::Generators::PermissionRoleGenerator, ActiveRecord::Zuul::Generators::PermissionSubjectGenerator, ActiveRecord::Zuul::Generators::RoleGenerator, ActiveRecord::Zuul::Generators::RoleSubjectGenerator, ActiveRecord::Zuul::Generators::SubjectGenerator
- Defined in:
- lib/generators/zuul/orm_helpers.rb
Instance Method Summary collapse
- #migration_exists?(type, table_name) ⇒ Boolean
- #migration_path ⇒ Object
- #model_exists? ⇒ Boolean
- #model_path ⇒ Object
Instance Method Details
#migration_exists?(type, table_name) ⇒ 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_path ⇒ Object
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
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_path ⇒ Object
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 |