Module: Lotus::Model
- Includes:
- Utils::ClassAttribute
- Defined in:
- lib/lotus/model.rb,
lib/lotus/model/mapper.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/coercer.rb,
lib/lotus/model/migrator/adapter.rb,
lib/lotus/model/adapters/abstract.rb,
lib/lotus/model/mapping/coercions.rb,
lib/lotus/model/adapters/sql/query.rb,
lib/lotus/model/mapping/collection.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/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: Configuration, InvalidMappingError, InvalidQueryError, Mapper, MigrationError, NoMappingError, NonPersistedEntityError, NullMapper
Constant Summary collapse
- VERSION =
Defines the version
'0.4.1'.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`
77 78 79 80 |
# File 'lib/lotus/model.rb', line 77 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
143 144 145 146 147 |
# File 'lib/lotus/model.rb', line 143 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
188 189 190 191 192 193 194 195 196 197 |
# File 'lib/lotus/model.rb', line 188 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
86 87 88 |
# File 'lib/lotus/model.rb', line 86 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.
50 51 52 |
# File 'lib/lotus/model/migrator.rb', line 50 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
94 95 96 |
# File 'lib/lotus/model.rb', line 94 def self.unload! configuration.unload! end |