Module: Lotus::Model
- Includes:
- Utils::ClassAttribute
- Defined in:
- lib/lotus/model.rb,
lib/lotus/model/error.rb,
lib/lotus/model/mapper.rb,
lib/lotus/model/coercer.rb,
lib/lotus/model/mapping.rb,
lib/lotus/model/version.rb,
lib/lotus/model/migrator.rb,
lib/lotus/model/config/mapper.rb,
lib/lotus/model/configuration.rb,
lib/lotus/model/config/adapter.rb,
lib/lotus/model/mapping/coercers.rb,
lib/lotus/model/migrator/adapter.rb,
lib/lotus/model/adapters/abstract.rb,
lib/lotus/model/mapping/attribute.rb,
lib/lotus/model/adapters/sql/query.rb,
lib/lotus/model/mapping/collection.rb,
lib/lotus/model/migrator/connection.rb,
lib/lotus/model/adapters/sql/command.rb,
lib/lotus/model/adapters/sql/console.rb,
lib/lotus/model/adapters/sql_adapter.rb,
lib/lotus/model/adapters/memory/query.rb,
lib/lotus/model/adapters/null_adapter.rb,
lib/lotus/model/migrator/mysql_adapter.rb,
lib/lotus/model/adapters/implementation.rb,
lib/lotus/model/adapters/memory/command.rb,
lib/lotus/model/adapters/memory_adapter.rb,
lib/lotus/model/adapters/sql/collection.rb,
lib/lotus/model/migrator/sqlite_adapter.rb,
lib/lotus/model/migrator/postgres_adapter.rb,
lib/lotus/model/adapters/memory/collection.rb,
lib/lotus/model/mapping/collection_coercer.rb,
lib/lotus/model/adapters/sql/consoles/mysql.rb,
lib/lotus/model/adapters/file_system_adapter.rb,
lib/lotus/model/adapters/sql/consoles/sqlite.rb,
lib/lotus/model/adapters/sql/consoles/postgresql.rb
Overview
Model
Defined Under Namespace
Modules: Adapters, Config, Mapping, Migrator Classes: Coercer, Configuration, Error, InvalidCommandError, InvalidMappingError, InvalidQueryError, Mapper, MigrationError, NoMappingError, NonPersistedEntityError, NullMapper
Constant Summary collapse
- VERSION =
Defines the version
'0.5.2'.freeze
Class Method Summary collapse
-
.configure(&blk) ⇒ Object
Configure the framework.
-
.dupe ⇒ Module
private
Duplicate Lotus::Model in order to create a new separated instance of the framework.
-
.duplicate(mod, &blk) ⇒ Module
Duplicate the framework and generate modules for the target application.
-
.load! ⇒ Object
private
Load the framework.
-
.migration(&blk) ⇒ Object
Define a migration.
-
.unload! ⇒ Object
private
Unload the framework.
Class Method Details
.configure(&blk) ⇒ Object
Configure the framework. It yields the given block in the context of the configuration
Adapter MUST follow the convention in which adapter class is inflection of adapter name The above example has name :sql, thus derived class will be ‘Lotus::Model::Adapters::SqlAdapter`
86 87 88 89 |
# File 'lib/lotus/model.rb', line 86 def self.configure(&blk) configuration.instance_eval(&blk) self end |
.dupe ⇒ Module
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.
Duplicate Lotus::Model in order to create a new separated instance of the framework.
The new instance of the framework will be completely decoupled from the original. It will inherit the configuration, but all the changes that happen after the duplication, won’t be reflected on the other copies.
@since 0.2.0
152 153 154 155 156 |
# File 'lib/lotus/model.rb', line 152 def self.dupe dup.tap do |duplicated| duplicated.configuration = Configuration.new end end |
.duplicate(mod, &blk) ⇒ Module
Duplicate the framework and generate modules for the target application
@since 0.2.0
197 198 199 200 201 202 203 204 205 206 |
# File 'lib/lotus/model.rb', line 197 def self.duplicate(mod, &blk) dupe.tap do |duplicated| mod.module_eval %{ Entity = Lotus::Entity.dup Repository = Lotus::Repository.dup } duplicated.configure(&blk) if block_given? end end |
.load! ⇒ 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.
Load the framework
95 96 97 |
# File 'lib/lotus/model.rb', line 95 def self.load! configuration.load! 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.
51 52 53 |
# File 'lib/lotus/model/migrator.rb', line 51 def self.migration(&blk) Sequel.migration(&blk) end |
.unload! ⇒ 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.
Unload the framework
103 104 105 |
# File 'lib/lotus/model.rb', line 103 def self.unload! configuration.unload! end |