lib/engine2/core.rb in engine2-1.0.2 vs lib/engine2/core.rb in engine2-1.0.3

- old
+ new

@@ -118,11 +118,11 @@ "<i class='fa fa-#{self}'></i>" end end class << Sequel - attr_accessor :alias_tables_in_joins + attr_accessor :alias_columns_in_joins def split_keys id id.split('|') end end @@ -145,11 +145,11 @@ end Sequel.quote_identifiers = false Sequel.extension :core_extensions Sequel::Inflections.clear -Sequel.alias_tables_in_joins = true +Sequel.alias_columns_in_joins = true # Sequel::Model.plugin :json_serializer, :naked => true # Sequel::Model.plugin :timestamps # Sequel::Model.plugin :validation_class_methods # Sequel::Model.raise_on_typecast_failure = false # Sequel::Model.raise_on_save_failure = false @@ -362,11 +362,11 @@ # # (~{name => nil}).as :name # # Sequel.char_length(name).as name # nil else if table != model_table_name - if Sequel.alias_tables_in_joins + if Sequel.alias_columns_in_joins name.qualify(table).as(:"#{table}__#{name}") else name.qualify(table) end else @@ -433,11 +433,11 @@ module Engine2 LOCS ||= Hash.new{|h, k| ":#{k}:"} PATH ||= File.expand_path('../..', File.dirname(__FILE__)) class << self - attr_reader :app, :reloading + attr_reader :app, :app_name, :reloading attr_reader :core_loaded def database name Object.const_set(name, yield) unless Object.const_defined?(name) end @@ -455,12 +455,12 @@ @model_boot_blk = blk end def bootstrap_e2db e2_db_file = (defined? JRUBY_VERSION) ? "jdbc:sqlite:#{@app}/engine2.db" : "sqlite://#{@app}/engine2.db" - Engine2.const_set :E2DB, connect(e2_db_file, loggers: [Logger.new($stdout)], convert_types: false, name: :engine2) - Engine2.const_set :DUMMYDB, Sequel::Database.new(uri: 'dummy') + const_set :E2DB, connect(e2_db_file, loggers: [Logger.new($stdout)], convert_types: false, name: :engine2) + const_set :DUMMYDB, Sequel::Database.new(uri: 'dummy') def DUMMYDB.synchronize *args;end end def reload @core_loaded = true @@ -480,19 +480,20 @@ load 'engine2/models/UserInfo.rb' Dir["#{app}/models/*"].each{|m| load m} puts "MODELS: #{Sequel::DATABASES.reduce(0){|s, d|s + d.models.size}}, Time: #{Time.now - t}" Sequel::DATABASES.each &:dump_schema_cache_to_file - Engine2.send(:remove_const, :ROOT) if defined? ROOT - Engine2.const_set(:ROOT, Action.new(nil, :api, DummyMeta, {})) + send(:remove_const, :ROOT) if defined? ROOT + const_set(:ROOT, Action.new(nil, :api, RootMeta, {})) @boot_blk.(ROOT) ROOT.setup_action_tree puts "BOOTSTRAP #{app}, Time: #{Time.new - t}" end def bootstrap app, opts = {} @app = app + @app_name = opts[:name] || File::basename(app) @reloading = opts[:reloading] bootstrap_e2db require 'engine2/pre_bootstrap' reload