Module: Hanami::Model
- Defined in:
- lib/hanami/model.rb,
lib/hanami/model/sql.rb,
lib/hanami/model/error.rb,
lib/hanami/model/types.rb,
lib/hanami/model/mapping.rb,
lib/hanami/model/plugins.rb,
lib/hanami/model/version.rb,
lib/hanami/model/migrator.rb,
lib/hanami/model/migration.rb,
lib/hanami/model/sql/types.rb,
lib/hanami/model/association.rb,
lib/hanami/model/entity_name.rb,
lib/hanami/model/sql/console.rb,
lib/hanami/model/configurator.rb,
lib/hanami/model/configuration.rb,
lib/hanami/model/relation_name.rb,
lib/hanami/model/plugins/schema.rb,
lib/hanami/model/mapped_relation.rb,
lib/hanami/model/migrator/logger.rb,
lib/hanami/model/plugins/mapping.rb,
lib/hanami/model/associations/dsl.rb,
lib/hanami/model/migrator/adapter.rb,
lib/hanami/model/sql/entity/schema.rb,
lib/hanami/model/plugins/timestamps.rb,
lib/hanami/model/sql/consoles/mysql.rb,
lib/hanami/model/migrator/connection.rb,
lib/hanami/model/sql/consoles/sqlite.rb,
lib/hanami/model/associations/has_one.rb,
lib/hanami/model/associations/has_many.rb,
lib/hanami/model/sql/consoles/abstract.rb,
lib/hanami/model/migrator/mysql_adapter.rb,
lib/hanami/model/associations/belongs_to.rb,
lib/hanami/model/migrator/sqlite_adapter.rb,
lib/hanami/model/sql/consoles/postgresql.rb,
lib/hanami/model/associations/many_to_many.rb,
lib/hanami/model/migrator/postgres_adapter.rb,
lib/hanami/model/sql/types/schema/coercions.rb
Overview
Hanami::Model migrations
Defined Under Namespace
Modules: Associations, Plugins, Sql, Types Classes: Association, CheckConstraintViolationError, Configuration, Configurator, ConstraintViolationError, DatabaseError, EntityName, Error, ForeignKeyConstraintViolationError, InvalidCommandError, MappedRelation, Mapping, Migration, MigrationError, Migrator, MissingPrimaryKeyError, NotNullConstraintViolationError, RelationName, UniqueConstraintViolationError, UnknownAttributeError, UnknownDatabaseAdapterError, UnknownDatabaseTypeError
Constant Summary collapse
- VERSION =
Defines the version
"1.3.3"
Class Attribute Summary collapse
- .config ⇒ Object readonly private
- .loaded ⇒ Object (also: loaded?) readonly private
Class Method Summary collapse
-
.configuration ⇒ Object
Current configuration.
-
.configure(&block) ⇒ Object
Configure the framework.
- .container ⇒ Object private
-
.disconnect ⇒ Object
Disconnect from the database.
- .load!(&blk) ⇒ Object
-
.migration(&blk) ⇒ Object
Define a migration.
- .repositories ⇒ Object private
Class Attribute Details
.config ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 |
# File 'lib/hanami/model.rb', line 30 def config @config end |
.loaded ⇒ Object (readonly) Also known as: loaded?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 |
# File 'lib/hanami/model.rb', line 34 def loaded @loaded end |
Class Method Details
.configuration ⇒ Object
Current configuration
62 63 64 |
# File 'lib/hanami/model.rb', line 62 def self.configuration @configuration ||= Configuration.new(config) end |
.configure(&block) ⇒ Object
Configure the framework
54 55 56 57 |
# File 'lib/hanami/model.rb', line 54 def self.configure(&block) @config = Configurator.build(&block) self end |
.container ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 77 78 |
# File 'lib/hanami/model.rb', line 74 def self.container raise "Not loaded" unless loaded? @container end |
.disconnect ⇒ Object
Disconnect from the database
This is useful for rebooting applications in production and to ensure that the framework prunes stale connections.
107 108 109 |
# File 'lib/hanami/model.rb', line 107 def self.disconnect configuration.connection&.disconnect end |
.load!(&blk) ⇒ Object
81 82 83 84 |
# File 'lib/hanami/model.rb', line 81 def self.load!(&blk) @container = configuration.load!(repositories, &blk) @loaded = true end |
.migration(&blk) ⇒ Object
Define a migration
It must define an up/down strategy to write schema changes (up) and to rollback them (down).
We can use up
and down
blocks for custom strategies, or only one change
block that automatically implements “down” strategy.
50 51 52 |
# File 'lib/hanami/model/sql.rb', line 50 def self.migration(&blk) Migration.new(configuration.gateways[:default], &blk) end |
.repositories ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
68 69 70 |
# File 'lib/hanami/model.rb', line 68 def self.repositories @__repositories__ end |