class Deimos::Generators::ActiveRecordGenerator
Generator for ActiveRecord model and migration.
Public Instance Methods
db_migrate_path()
click to toggle source
@return [String]
# File lib/generators/deimos/active_record_generator.rb, line 26 def db_migrate_path if defined?(Rails.application) && Rails.application paths = Rails.application.config.paths['db/migrate'] paths.respond_to?(:to_ary) ? paths.to_ary.first : paths.to_a.first else 'db/migrate' end end
fields()
click to toggle source
@return [Array<SchemaField>]
# File lib/generators/deimos/active_record_generator.rb, line 65 def fields schema_base.schema_fields end
migration_version()
click to toggle source
@return [String]
# File lib/generators/deimos/active_record_generator.rb, line 36 def migration_version "[#{ActiveRecord::Migration.current_version}]" rescue StandardError '' end
namespace()
click to toggle source
@return [String]
# File lib/generators/deimos/active_record_generator.rb, line 54 def namespace last_dot = self.full_schema.rindex('.') self.full_schema[0...last_dot] end
schema()
click to toggle source
@return [String]
# File lib/generators/deimos/active_record_generator.rb, line 48 def schema last_dot = self.full_schema.rindex('.') self.full_schema[last_dot + 1..-1] end
schema_base()
click to toggle source
@return [Deimos::SchemaBackends::Base]
# File lib/generators/deimos/active_record_generator.rb, line 60 def schema_base @schema_base ||= Deimos.schema_backend_class.new(schema: schema, namespace: namespace) end
table_class()
click to toggle source
@return [String]
# File lib/generators/deimos/active_record_generator.rb, line 43 def table_class self.table_name.classify end