lib/engine2/core.rb in engine2-1.0.3 vs lib/engine2/core.rb in engine2-1.0.4
- old
+ new
@@ -121,11 +121,11 @@
class << Sequel
attr_accessor :alias_columns_in_joins
def split_keys id
- id.split('|')
+ id.split(Engine2::SETTINGS[:key_separator])
end
end
class Sequel::Database
attr_accessor :models, :default_schema
@@ -334,11 +334,11 @@
if table == model_table_name
m = model
else
a = model.many_to_one_associations[table] # || model.one_to_one_associations[table]
raise Engine2::E2Error.new("Association #{table} not found for model #{model}") unless a
- m = Object.const_get(a[:class_name])
+ m = a.associated_class
end
# raise Engine2::E2Error.new("Model not found for table #{table} in model #{model}") unless m
info = m.type_info
else
info = type_info
@@ -377,11 +377,11 @@
end
@opts[:select].compact!
joins.reduce(self) do |joined, (table, assoc)|
- m = Object.const_get(assoc[:class_name])
+ m = assoc.associated_class
keys = assoc[:qualified_key]
joined.left_join(table, m.primary_keys.zip(keys.is_a?(Array) ? keys : [keys]))
end
end
@@ -393,11 +393,11 @@
else
yield nil, sel, al
end
when Sequel::SQL::QualifiedIdentifier
yield sel.table, sel.column, al
- when Sequel::SQL::AliasedExpression
+ when Sequel::SQL::AliasedExpression, Sequel::SQL::Function
sel
# extract_select sel.expression, sel.aliaz, &blk
# expr = sel.expression
# yield expr.table, expr.column
else
@@ -431,13 +431,14 @@
end
module Engine2
LOCS ||= Hash.new{|h, k| ":#{k}:"}
PATH ||= File.expand_path('../..', File.dirname(__FILE__))
+ SETTINGS ||= {key_separator: '|'}
class << self
- attr_reader :app, :app_name, :reloading
+ attr_reader :app
attr_reader :core_loaded
def database name
Object.const_set(name, yield) unless Object.const_defined?(name)
end
@@ -488,13 +489,13 @@
@boot_blk.(ROOT)
ROOT.setup_action_tree
puts "BOOTSTRAP #{app}, Time: #{Time.new - t}"
end
- def bootstrap app, opts = {}
+ def bootstrap app, settings = {}
@app = app
- @app_name = opts[:name] || File::basename(app)
- @reloading = opts[:reloading]
+ SETTINGS.merge! settings
+ SETTINGS[:name] ||= File::basename(app)
bootstrap_e2db
require 'engine2/pre_bootstrap'
reload
require 'engine2/post_bootstrap'