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/oracle.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/oracle.old.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/adapter/oracle/utils.rb,
lib/og/relation/many_to_many.rb

Overview

require 'og/adapter/oracle/override' require 'og/adapter/oracle/utils'

Defined Under Namespace

Modules: EntityMixin, Evolution, MysqlUtils, OracleUtils, RelationDSL, SchemaInheritanceBase, SqlUtils, Unmanageable Classes: Adapter, BelongsTo, Blob, Collection, Entity, HasMany, HasManyCollection, HasOne, JoinsMany, JoinsManyCollection, Manager, ManyToMany, MysqlAdapter, OracleAdapter, PostgresqlAdapter, RefersTo, Relation, SqlStore, SqliteAdapter, Store, StoreException

Constant Summary collapse

Version =

The version.

'0.41.0'
LibPath =

Library path.

File.dirname(__FILE__)
NotNull =
{ :sql => 'NOT NULL' }.freeze
Null =
{ :sql => 'NULL' }.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.managerObject

The active manager


126
127
128
# File 'lib/og.rb', line 126

def manager
  @manager
end

.thread_safeObject

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(options = Og.manager_options)
  # Use sqlite as the default adapter.
  
  unless options[:adapter] || options[:store]
    options[: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.

  options[:called_by_og_setup] = true if options[:called_by_og_setup].nil?

  @thread_safe = true

  m = @manager = Manager.new(options)        
  m.manage_classes(options[: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 options[:called_by_og_setup]
  
  return m
rescue Exception => ex 
  Logger.error "#{ex.class} in Og.setup:"
  Logger.error ex.message
  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