Module: DataMapper
- Extended by:
- Assertions
- Defined in:
- lib/dm-core.rb,
lib/dm-core.rb,
lib/dm-core/type.rb,
lib/dm-core/model.rb,
lib/dm-core/query.rb,
lib/dm-core/version.rb,
lib/dm-core/adapters.rb,
lib/dm-core/model/is.rb,
lib/dm-core/property.rb,
lib/dm-core/resource.rb,
lib/dm-core/collection.rb,
lib/dm-core/model/hook.rb,
lib/dm-core/query/path.rb,
lib/dm-core/query/sort.rb,
lib/dm-core/repository.rb,
lib/dm-core/spec/setup.rb,
lib/dm-core/types/text.rb,
lib/dm-core/model/scope.rb,
lib/dm-core/identity_map.rb,
lib/dm-core/property_set.rb,
lib/dm-core/support/hook.rb,
lib/dm-core/types/object.rb,
lib/dm-core/types/serial.rb,
lib/dm-core/property/date.rb,
lib/dm-core/property/text.rb,
lib/dm-core/property/time.rb,
lib/dm-core/types/boolean.rb,
lib/dm-core/types/decimal.rb,
lib/dm-core/model/property.rb,
lib/dm-core/property/class.rb,
lib/dm-core/property/float.rb,
lib/dm-core/query/operator.rb,
lib/dm-core/resource/state.rb,
lib/dm-core/support/logger.rb,
lib/dm-core/property/binary.rb,
lib/dm-core/property/lookup.rb,
lib/dm-core/property/object.rb,
lib/dm-core/property/serial.rb,
lib/dm-core/property/string.rb,
lib/dm-core/query/direction.rb,
lib/dm-core/support/subject.rb,
lib/dm-core/property/boolean.rb,
lib/dm-core/property/decimal.rb,
lib/dm-core/property/integer.rb,
lib/dm-core/property/numeric.rb,
lib/dm-core/support/chainable.rb,
lib/dm-core/support/deprecate.rb,
lib/dm-core/support/equalizer.rb,
lib/dm-core/model/relationship.rb,
lib/dm-core/property/date_time.rb,
lib/dm-core/support/assertions.rb,
lib/dm-core/types/discriminator.rb,
lib/dm-core/resource/state/clean.rb,
lib/dm-core/resource/state/dirty.rb,
lib/dm-core/spec/lib/spec_helper.rb,
lib/dm-core/property/discriminator.rb,
lib/dm-core/property/typecast/time.rb,
lib/dm-core/resource/state/deleted.rb,
lib/dm-core/support/descendant_set.rb,
lib/dm-core/associations/one_to_one.rb,
lib/dm-core/associations/many_to_one.rb,
lib/dm-core/associations/one_to_many.rb,
lib/dm-core/resource/state/immutable.rb,
lib/dm-core/resource/state/persisted.rb,
lib/dm-core/resource/state/transient.rb,
lib/dm-core/spec/lib/adapter_helpers.rb,
lib/dm-core/spec/lib/pending_helpers.rb,
lib/dm-core/adapters/abstract_adapter.rb,
lib/dm-core/associations/many_to_many.rb,
lib/dm-core/associations/relationship.rb,
lib/dm-core/property/typecast/numeric.rb,
lib/dm-core/adapters/in_memory_adapter.rb,
lib/dm-core/query/conditions/operation.rb,
lib/dm-core/support/local_object_space.rb,
lib/dm-core/support/naming_conventions.rb,
lib/dm-core/query/conditions/comparison.rb,
lib/dm-core/spec/lib/collection_helpers.rb
Overview
TODO: move argument and option validation into the class
Defined Under Namespace
Modules: Adapters, Assertions, Associations, Chainable, Deprecate, Equalizer, Hook, LocalObjectSpace, Model, NamingConventions, Resource, Spec, Subject, Types, Undefined Classes: Collection, DescendantSet, IdentityMap, ImmutableDeletedError, ImmutableError, IncompleteModelError, Logger, ObjectNotFoundError, PersistenceError, PluginNotFoundError, Property, PropertySet, Query, Repository, RepositoryNotSetupError, SaveFailureError, Type, UnknownRelationshipError, UnsavedParentError, UpdateConflictError
Constant Summary collapse
- VERSION =
'1.0.0'
Class Attribute Summary collapse
-
.logger ⇒ Object
Returns the value of attribute logger.
Class Method Summary collapse
-
.finalize ⇒ DataMapper
Perform necessary steps to finalize DataMapper for the current repository.
-
.repository(name = nil) {|Proc| ... } ⇒ Object
Block Syntax Pushes the named repository onto the context-stack, yields a new session, and pops the context-stack.
- .root ⇒ Object private
-
.setup(*args) ⇒ DataMapper::Adapters::AbstractAdapter
Setups up a connection to a data-store.
- .Type(primitive_type, options = {}) ⇒ Object deprecated Deprecated.
Methods included from Assertions
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
37 38 39 |
# File 'lib/dm-core/support/logger.rb', line 37 def logger @logger end |
Class Method Details
.finalize ⇒ DataMapper
Perform necessary steps to finalize DataMapper for the current repository
This method should be called after loading all models and plugins.
It ensures foreign key properties and anonymous join models are created. These are otherwise lazily declared, which can lead to unexpected errors. It also performs basic validity checking of the DataMapper models.
316 317 318 319 320 321 |
# File 'lib/dm-core.rb', line 316 def self.finalize Model.descendants.each do |model| finalize_model(model) end self end |
.repository(name = nil) {|Proc| ... } ⇒ Object
Block Syntax
Pushes the named repository onto the context-stack,
yields a new session, and pops the context-stack.
Non-Block Syntax
Returns the current session, or if there is none,
a new Session.
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/dm-core.rb', line 285 def self.repository(name = nil) context = Repository.context current_repository = if name name = name.to_sym context.detect { |repository| repository.name == name } else name = Repository.default_name context.last end current_repository ||= Repository.new(name) if block_given? current_repository.scope { |*block_args| yield(*block_args) } else current_repository end end |
.root ⇒ 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.
241 242 243 |
# File 'lib/dm-core.rb', line 241 def self.root @root ||= Pathname(__FILE__).dirname.parent..freeze end |
.setup(*args) ⇒ DataMapper::Adapters::AbstractAdapter
Setups up a connection to a data-store
262 263 264 265 266 267 268 269 270 |
# File 'lib/dm-core.rb', line 262 def self.setup(*args) adapter = args.first unless adapter.kind_of?(Adapters::AbstractAdapter) adapter = Adapters.new(*args) end Repository.adapters[adapter.name] = adapter end |
.Type(primitive_type, options = {}) ⇒ Object
211 212 213 214 |
# File 'lib/dm-core/type.rb', line 211 def self.Type(primitive_type, = {}) warn "DataMapper.Type(#{primitive_type}) is deprecated, specify the primitive and options explicitly (#{caller[0]})" Class.new(Type).configure(primitive_type, ) end |