Module: Og
- Defined in:
- lib/og.rb,
lib/og/dump.rb,
lib/og/store.rb,
lib/og/types.rb,
lib/og/entity.rb,
lib/og/errors.rb,
lib/og/adapter.rb,
lib/og/manager.rb,
lib/og/markers.rb,
lib/og/relation.rb,
lib/og/store/sql.rb,
lib/og/collection.rb,
lib/og/adapter/mysql.rb,
lib/og/adapter/sqlite.rb,
lib/og/store/sql/join.rb,
lib/og/store/sql/utils.rb,
lib/og/relation/has_one.rb,
lib/og/relation/has_many.rb,
lib/og/adapter/postgresql.rb,
lib/og/relation/refers_to.rb,
lib/og/adapter/mysql/utils.rb,
lib/og/relation/belongs_to.rb,
lib/og/relation/joins_many.rb,
lib/og/store/sql/evolution.rb,
lib/og/relation/many_to_many.rb
Overview
Og (ObjectGraph) manages Ruby objects and their relations and provides transparent and efficient object-relational mapping and querying mechanisms.
Property Metadata
Og defines, reserves and uses the following property metadata types:
:sql_index
-
Create an sql index for this property.
:unique
-
This value of the property must be unique.
Design
Og allows the serialization of arbitrary Ruby objects. Just mark them as Object (or Array or Hash) in the attr_accessor and the engine will serialize a YAML dump of the object. Arbitrary object graphs are supported too.
Defined Under Namespace
Modules: EntityMixin, Evolution, MysqlUtils, RelationDSL, SchemaInheritanceBase, SqlUtils, Unmanageable Classes: Adapter, BelongsTo, Blob, Collection, Entity, HasMany, HasManyCollection, HasOne, JoinsMany, JoinsManyCollection, Manager, ManyToMany, MysqlAdapter, PostgresqlAdapter, RefersTo, Relation, SqlStore, SqliteAdapter, Store, StoreException
Constant Summary collapse
- Version =
The version.
'0.40.0'
- LibPath =
Library path.
File.dirname(__FILE__)
- NotNull =
{ :sql => 'NOT NULL' }.freeze
- Null =
{ :sql => 'NULL' }.freeze
Class Attribute Summary collapse
-
.manager ⇒ Object
The active manager.
-
.thread_safe ⇒ Object
thread safe state.
Class Method Summary collapse
-
.escape(str) ⇒ Object
Helper method.
-
.quote(str) ⇒ Object
Quote the string.
-
.start(options = Og.manager_options) ⇒ Object
(also: run, connect, setup, setup=)
Helper method, useful to initialize Og.
-
.VarChar(size) ⇒ Object
Some useful type macros to help when defining properties.
Class Attribute Details
.manager ⇒ Object
The active manager
126 127 128 |
# File 'lib/og.rb', line 126 def manager @manager end |
.thread_safe ⇒ Object
thread safe state
130 131 132 |
# File 'lib/og.rb', line 130 def thread_safe @thread_safe end |
Class Method Details
.escape(str) ⇒ Object
Helper method.
180 181 182 |
# File 'lib/og.rb', line 180 def escape(str) @manager.store.escape(str) end |
.quote(str) ⇒ Object
Quote the string.
186 187 188 |
# File 'lib/og.rb', line 186 def quote(str) @manager.store.quote(str) end |
.start(options = Og.manager_options) ⇒ Object Also known as: run, connect, setup, setup=
Helper method, useful to initialize Og. If no options are passed, sqlite is selected as the default store.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/og.rb', line 136 def start( = Og.) # Use sqlite as the default adapter. unless [:adapter] || [:store] [:adapter] = :sqlite end # This is a flag a store or manager can use to determine # if it was being called by Og.setup to provide # additional, faster or enhanced functionality. [:called_by_og_setup] = true if [:called_by_og_setup].nil? @thread_safe = true m = @manager = Manager.new() m.manage_classes([:classes]) # Allows functionality that requires an initialized # store to be implemented. A vastly superior # method of constructing foreign key constraints is an # example of functionality this provides. Currently # only used by the PostgreSQL store. m.post_setup if [:called_by_og_setup] return m rescue Exception => ex Logger.error "#{ex.class} in Og.setup:" Logger.error ex. if $DBG Logger.error ex.backtrace.join("\n") exit end end |
.VarChar(size) ⇒ Object
Some useful type macros to help when defining properties. You can easily code your own type macros. Just return the array that should be passed to the attr_xxx macros.
Example
attr_accessor :name, VarChar(30)
11 12 13 |
# File 'lib/og/types.rb', line 11 def self.VarChar(size) return String, :sql => "VARCHAR(#{size})" end |