ooor 1.4.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +10 -70
- data/lib/app/models/base64.rb +1 -1
- data/lib/app/models/common_service.rb +21 -20
- data/lib/app/models/db_service.rb +22 -20
- data/lib/app/models/ooor_client.rb +41 -0
- data/lib/app/models/open_object_resource.rb +325 -411
- data/lib/app/models/relation.rb +145 -0
- data/lib/app/models/type_casting.rb +119 -0
- data/lib/app/models/uml.rb +173 -150
- data/lib/app/ui/action_window.rb +82 -8
- data/lib/app/ui/client_base.rb +26 -29
- data/lib/app/ui/form_model.rb +63 -62
- data/lib/app/ui/menu.rb +12 -11
- data/lib/ooor.rb +90 -77
- data/spec/ooor_spec.rb +41 -34
- metadata +49 -46
data/lib/app/ui/action_window.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# OOOR: Open Object On Rails
|
2
|
-
# Copyright (C) 2009-
|
2
|
+
# Copyright (C) 2009-2011 Akretion LTDA (<http://www.akretion.com>).
|
3
3
|
# Author: Raphaël Valyi
|
4
4
|
#
|
5
5
|
# This program is free software: you can redistribute it and/or modify
|
@@ -14,15 +14,89 @@
|
|
14
14
|
#
|
15
15
|
# You should have received a copy of the GNU Affero General Public License
|
16
16
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
module Ooor
|
18
|
+
class ActionWindow
|
19
|
+
class << self
|
20
|
+
attr_accessor :klass, :openerp_act_window, :views
|
21
|
+
|
22
|
+
def from_menu(menu)
|
23
|
+
act_win_class = Class.new(ActionWindow)
|
24
|
+
act_win_class.openerp_act_window = menu.action
|
25
|
+
act_win_class.klass = menu.class.const_get(menu.action.res_model)
|
26
|
+
act_win_class.views = {}
|
27
|
+
act_win_class
|
28
|
+
end
|
29
|
+
|
30
|
+
def from_act_window(act_window)
|
31
|
+
act_win_class = Class.new(ActionWindow)
|
32
|
+
act_win_class.openerp_act_window = act_window
|
33
|
+
act_win_class.klass = act_window.class.const_get(act_window.res_model)
|
34
|
+
act_win_class.views = {}
|
35
|
+
act_win_class
|
36
|
+
end
|
37
|
+
|
38
|
+
def from_model(act_window_param)
|
39
|
+
act_win_class = Class.new(ActionWindow)
|
40
|
+
act_win_class.openerp_act_window = IrActionsAct_window.find(:first, :domain=>[['res_model', '=', act_window_param.openerp_model]])
|
41
|
+
act_win_class.klass = act_window_param
|
42
|
+
act_win_class.views = {}
|
43
|
+
act_win_class
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_view_id(mode)
|
47
|
+
IrActionsAct_window.read(@openerp_act_window.id, ["view_ids"])["view_ids"]
|
48
|
+
IrActionsAct_windowView.read([9,10], ["view_mode"]).each do |view_hash|
|
49
|
+
return view_hash["id"] if view_hash["view_mode"] == mode.to_s
|
50
|
+
end
|
51
|
+
IrUiView.search([['model', '=', act_window_param.openerp_model], ['type', '=', mode.to_s]])
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_fields(mode)
|
55
|
+
@views[mode] ||= @klass.fields_view_get(get_view_id(mode), mode)
|
56
|
+
@views[mode]['fields'] #TODO order by occurrence in view XML
|
57
|
+
end
|
58
|
+
|
59
|
+
def column_names
|
60
|
+
reload_fields_definition
|
61
|
+
@column_names ||= ["id"] + get_fields('tree').keys()
|
62
|
+
end
|
63
|
+
|
64
|
+
def columns_hash
|
65
|
+
reload_fields_definition
|
66
|
+
unless @column_hash
|
67
|
+
@column_hash = {"id" => {"string"=>"Id", "type"=>"integer"}}.merge(get_fields('tree'))
|
68
|
+
def @column_hash.type
|
69
|
+
col_type = @column_hash['type'].to_sym #TODO mapping ?
|
70
|
+
col_type == :char && :string || col_type
|
71
|
+
end
|
72
|
+
end
|
73
|
+
@column_hash
|
74
|
+
end
|
75
|
+
|
76
|
+
def primary_key
|
77
|
+
"id"
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_arch(mode)
|
81
|
+
#TODO
|
82
|
+
end
|
83
|
+
|
84
|
+
def open(mode='tree', ids=nil)#TODO: fix!
|
85
|
+
if view_mode.index(mode)
|
86
|
+
the_view_id = false
|
87
|
+
relations['views'].each do |tuple|
|
88
|
+
the_view_id = tuple[0] if tuple[1] == mode
|
89
|
+
end
|
90
|
+
self.class.ooor.build_object_view(self.class.ooor.const_get(res_model), the_view_id, mode, domain || [], ids, {})
|
91
|
+
end
|
92
|
+
end
|
17
93
|
|
18
|
-
|
19
|
-
|
20
|
-
if view_mode.index(mode)
|
21
|
-
the_view_id = false
|
22
|
-
relations['views'].each do |tuple|
|
23
|
-
the_view_id = tuple[0] if tuple[1] == mode
|
94
|
+
def method_missing(method, *args, &block)
|
95
|
+
@klass.send(method, *args, &block)
|
24
96
|
end
|
25
|
-
|
97
|
+
|
26
98
|
end
|
99
|
+
|
100
|
+
|
27
101
|
end
|
28
102
|
end
|
data/lib/app/ui/client_base.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# OOOR: Open Object On Rails
|
2
|
-
# Copyright (C) 2009-
|
2
|
+
# Copyright (C) 2009-2011 Akretion LTDA (<http://www.akretion.com>).
|
3
3
|
# Author: Raphaël Valyi
|
4
4
|
#
|
5
5
|
# This program is free software: you can redistribute it and/or modify
|
@@ -19,38 +19,35 @@ require 'app/ui/form_model'
|
|
19
19
|
require 'app/ui/menu'
|
20
20
|
require 'app/ui/action_window'
|
21
21
|
|
22
|
-
module
|
22
|
+
module Ooor
|
23
|
+
module ClientBase
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
def action_window_class
|
30
|
-
const_get('ir.actions.act_window').send :include, ActionWindowModule
|
31
|
-
end
|
32
|
-
|
33
|
-
def get_init_menu(user_id=@config[:user_id])
|
34
|
-
const_get('res.users').read([user_id], ['menu_id', 'name'], @global_context)
|
35
|
-
end
|
25
|
+
def menu_class
|
26
|
+
const_get('ir.ui.menu').send :include, MenuModule
|
27
|
+
end
|
36
28
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
FormModel.new(wizard_name, result[0], nil, nil, result[1], [self], @global_context)#TODO set arch and fields
|
41
|
-
end
|
29
|
+
def get_init_menu(user_id=@config[:user_id])
|
30
|
+
const_get('res.users').read([user_id], ['menu_id', 'name'], @global_context)
|
31
|
+
end
|
42
32
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
ids = const_get(view['model']).search(domain) unless ids #TODO replace by search_read once OpenERP has that
|
48
|
-
values = const_get(view['model']).read(ids, view['fields'], context)
|
49
|
-
models = []
|
50
|
-
ids.each_with_index do |id, k|
|
51
|
-
models << const_get(view['model']).new(values[k], [], context)
|
33
|
+
#Ooor can have wizards that are not object related, for instance to configure the initial database:
|
34
|
+
def old_wizard_step(wizard_name, step='init', wizard_id=nil, form={}, context={})
|
35
|
+
result = @ir_model_class.old_wizard_step(wizard_name, nil, step, wizard_id, form, {})
|
36
|
+
FormModel.new(wizard_name, result[0], nil, nil, result[1], [self], @global_context)#TODO set arch and fields
|
52
37
|
end
|
53
38
|
|
54
|
-
|
39
|
+
def build_object_view(model_class, view_id, view_mode='form', domain=[], ids=nil, context={}, toolbar=false)
|
40
|
+
#TODO put in cache eventually:
|
41
|
+
view = model_class.fields_view_get(view_id, view_mode, @global_context, toolbar)
|
42
|
+
context = @global_context.merge(context)
|
43
|
+
ids = const_get(view['model']).search(domain) unless ids #TODO replace by search_read once OpenERP has that
|
44
|
+
values = const_get(view['model']).read(ids, view['fields'], context)
|
45
|
+
models = []
|
46
|
+
ids.each_with_index do |id, k|
|
47
|
+
models << const_get(view['model']).new(values[k], [], context)
|
48
|
+
end
|
49
|
+
|
50
|
+
FormModel.new(view['name'], view['view_id'], view['arch'], view['fields'], nil, models, context, view['view_id'])
|
51
|
+
end
|
55
52
|
end
|
56
53
|
end
|
data/lib/app/ui/form_model.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# OOOR: Open Object On Rails
|
2
|
-
# Copyright (C) 2009-
|
2
|
+
# Copyright (C) 2009-2011 Akretion LTDA (<http://www.akretion.com>).
|
3
3
|
# Author: Raphaël Valyi
|
4
4
|
#
|
5
5
|
# This program is free software: you can redistribute it and/or modify
|
@@ -14,85 +14,86 @@
|
|
14
14
|
#
|
15
15
|
# You should have received a copy of the GNU Affero General Public License
|
16
16
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
module Ooor
|
18
|
+
class FormModel
|
19
|
+
attr_accessor :name, :wizard_id, :datas, :arch, :fields, :type, :state, :view_id, :open_object_resources, :view_context
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@type = data['type']
|
31
|
-
update_wizard_state(data['state'])
|
21
|
+
def initialize(name, wizard_id, arch, fields, data, open_object_resources, view_context, view_id=nil)
|
22
|
+
@arch = arch
|
23
|
+
@fields = fields
|
24
|
+
@name = name
|
25
|
+
@wizard_id = wizard_id
|
26
|
+
@open_object_resources = open_object_resources
|
27
|
+
@view_context = view_context
|
28
|
+
if data #it's a wizard
|
29
|
+
@datas = data['datas'].symbolize_keys!
|
30
|
+
@type = data['type']
|
31
|
+
update_wizard_state(data['state'])
|
32
|
+
end
|
32
33
|
end
|
33
|
-
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
def to_html
|
36
|
+
"<div>not implemented in OOOR core gem!</div>"
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
39
|
+
def to_s
|
40
|
+
content = ""
|
41
|
+
content << @name
|
42
|
+
@open_object_resources.each do |resource|
|
43
|
+
content << "\n---------"
|
44
|
+
@fields.each do |k, v| #TODO no need for new call if many2one
|
45
|
+
if v['type'] == 'many2one'
|
46
|
+
content << "\n#{k}: #{resource.relations[k]}"
|
47
|
+
else
|
48
|
+
content << "\n#{k}: #{resource.send(k)}"
|
49
|
+
end
|
49
50
|
end
|
50
51
|
end
|
51
52
|
end
|
52
|
-
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
if open_object_resource.is_a? Ooor
|
60
|
-
data = open_object_resource.ir_model_class.old_wizard_step(@name, nil, method_symbol, @wizard_id, values, context)
|
61
|
-
else
|
62
|
-
data = open_object_resource.class.old_wizard_step(@name, [open_object_resource.id], method_symbol, @wizard_id, values, context)
|
63
|
-
end
|
64
|
-
if data[1]['state'] == 'end'
|
54
|
+
def old_wizard_step(method_symbol, *arguments)
|
55
|
+
values = @datas.merge!((arguments[0] || {}).symbolize_keys!)
|
56
|
+
context = @view_context.merge(arguments[1] || {})
|
57
|
+
if @open_object_resources.size == 1
|
58
|
+
open_object_resource = @open_object_resources[0]
|
65
59
|
if open_object_resource.is_a? Ooor
|
66
|
-
|
60
|
+
data = open_object_resource.ir_model_class.old_wizard_step(@name, nil, method_symbol, @wizard_id, values, context)
|
67
61
|
else
|
68
|
-
|
62
|
+
data = open_object_resource.class.old_wizard_step(@name, [open_object_resource.id], method_symbol, @wizard_id, values, context)
|
63
|
+
end
|
64
|
+
if data[1]['state'] == 'end'
|
65
|
+
if open_object_resource.is_a? Ooor
|
66
|
+
return 'end'
|
67
|
+
else
|
68
|
+
return open_object_resource.reload_from_record!(open_object_resource.class.find(open_object_resource.id, :context => context))
|
69
|
+
end
|
69
70
|
end
|
71
|
+
@arch = data[1]['arch']
|
72
|
+
@fields = data[1]['fields']
|
73
|
+
@datas.merge!(data[1]['datas'].symbolize_keys!) unless data[1]['datas'].empty?
|
74
|
+
@type = data[1]['type']
|
75
|
+
update_wizard_state(data[1]['state']) #FIXME ideally we should remove old methods
|
76
|
+
return self
|
77
|
+
else
|
78
|
+
ids = @open_object_resources.collect{ |open_object_resources| open_object_resources.id }
|
79
|
+
return open_object_resource.class.old_wizard_step(@name, ids, method_symbol, @wizard_id, values, context)
|
70
80
|
end
|
71
|
-
@arch = data[1]['arch']
|
72
|
-
@fields = data[1]['fields']
|
73
|
-
@datas.merge!(data[1]['datas'].symbolize_keys!) unless data[1]['datas'].empty?
|
74
|
-
@type = data[1]['type']
|
75
|
-
update_wizard_state(data[1]['state']) #FIXME ideally we should remove old methods
|
76
|
-
return self
|
77
|
-
else
|
78
|
-
ids = @open_object_resources.collect{ |open_object_resources| open_object_resources.id }
|
79
|
-
return open_object_resource.class.old_wizard_step(@name, ids, method_symbol, @wizard_id, values, context)
|
80
81
|
end
|
81
|
-
end
|
82
82
|
|
83
|
-
|
83
|
+
private
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
85
|
+
def update_wizard_state(state)
|
86
|
+
if state.is_a? Array
|
87
|
+
@state = state
|
88
|
+
@state.each do |state_item| #generates autocompletion handles
|
89
|
+
self.class_eval do
|
90
|
+
define_method state_item[0] do |*args|
|
91
|
+
self.send :old_wizard_step, *[state_item[0], *args]
|
92
|
+
end
|
92
93
|
end
|
93
94
|
end
|
94
95
|
end
|
95
96
|
end
|
96
|
-
end
|
97
97
|
|
98
|
+
end
|
98
99
|
end
|
data/lib/app/ui/menu.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# OOOR: Open Object On Rails
|
2
|
-
# Copyright (C) 2009-
|
2
|
+
# Copyright (C) 2009-2011 Akretion LTDA (<http://www.akretion.com>).
|
3
3
|
# Author: Raphaël Valyi
|
4
4
|
#
|
5
5
|
# This program is free software: you can redistribute it and/or modify
|
@@ -16,18 +16,19 @@
|
|
16
16
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
17
|
|
18
18
|
require 'app/ui/action_window'
|
19
|
+
module Ooor
|
20
|
+
module MenuModule
|
19
21
|
|
20
|
-
|
22
|
+
attr_accessor :menu_action
|
21
23
|
|
22
|
-
|
24
|
+
def menu_action
|
25
|
+
#TODO put in cache eventually:
|
26
|
+
action_values = self.class.ooor.const_get('ir.values').rpc_execute('get', 'action', 'tree_but_open', [['ir.ui.menu', id]], false, self.class.ooor.global_context)[0][2]#get already exists
|
27
|
+
@menu_action = self.class.ooor.const_get('ir.actions.act_window').new(action_values, []) #TODO deal with action reference instead
|
28
|
+
end
|
23
29
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@menu_action = self.class.ooor.const_get('ir.actions.act_window').new(action_values, []) #TODO deal with action reference instead
|
28
|
-
end
|
29
|
-
|
30
|
-
def open(mode='tree', ids=nil)
|
31
|
-
menu_action.open(mode, ids)
|
30
|
+
def open(mode='tree', ids=nil)
|
31
|
+
menu_action.open(mode, ids)
|
32
|
+
end
|
32
33
|
end
|
33
34
|
end
|
data/lib/ooor.rb
CHANGED
@@ -23,90 +23,103 @@ require 'app/models/common_service'
|
|
23
23
|
require 'app/models/base64'
|
24
24
|
require 'app/ui/client_base'
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
module Ooor
|
27
|
+
def self.new(*args)
|
28
|
+
Ooor.send :new, *args
|
29
|
+
end
|
30
|
+
|
31
|
+
class Ooor
|
32
|
+
include UML
|
33
|
+
include DbService
|
34
|
+
include CommonService
|
35
|
+
include ClientBase
|
31
36
|
|
32
|
-
|
33
|
-
|
37
|
+
cattr_accessor :default_ooor, :default_config
|
38
|
+
attr_accessor :logger, :config, :loaded_models, :base_url, :global_context, :ir_model_class
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
#load the custom configuration
|
41
|
+
def self.load_config(config_file=nil, env=nil)
|
42
|
+
config_file ||= defined?(Rails.root) && "#{Rails.root}/config/ooor.yml" || 'ooor.yml'
|
43
|
+
@config = YAML.load_file(config_file)[env || 'development']
|
44
|
+
rescue SystemCallError
|
45
|
+
puts """failed to load OOOR yaml configuration file.
|
46
|
+
make sure your app has a #{config_file} file correctly set up
|
47
|
+
if not, just copy/paste the default ooor.yml file from the OOOR Gem
|
48
|
+
to #{Rails.root}/config/ooor.yml and customize it properly\n\n"""
|
49
|
+
{}
|
50
|
+
end
|
46
51
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
load_models()
|
52
|
+
def initialize(config, env=false)
|
53
|
+
@config = config.is_a?(String) ? Ooor.load_config(config, env) : config
|
54
|
+
@config.symbolize_keys!
|
55
|
+
@logger = ((defined?(Rails) && $0 != 'irb' && Rails.logger || config[:force_rails_logger]) ? Rails.logger : Logger.new($stdout))
|
56
|
+
@logger.level = config[:log_level] if config[:log_level]
|
57
|
+
OpenObjectResource.logger = @logger
|
58
|
+
@base_url = config[:url].gsub(/\/$/,'')
|
59
|
+
@loaded_models = []
|
60
|
+
scope = Module.new and Object.const_set(config[:scope_prefix], scope) if config[:scope_prefix]
|
61
|
+
load_models() if config[:database]
|
58
62
|
end
|
59
|
-
end
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
+
def const_get(model_key)
|
65
|
+
@ir_model_class.const_get(model_key)
|
66
|
+
end
|
64
67
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
def load_models(to_load_models=@config[:models])
|
69
|
+
@global_context = @config[:global_context] || {}
|
70
|
+
global_login(@config[:username] || 'admin', @config[:password] || 'admin')
|
71
|
+
@ir_model_class = define_openerp_model({'model' => 'ir.model'}, @config[:scope_prefix])
|
72
|
+
if to_load_models #we load only a customized subset of the OpenERP models
|
73
|
+
model_ids = @ir_model_class.search([['model', 'in', to_load_models]])
|
74
|
+
else #we load all the models
|
75
|
+
model_ids = @ir_model_class.search() - [1]
|
76
|
+
end
|
77
|
+
models = @ir_model_class.read(model_ids, ['name', 'model', 'id', 'info', 'state'])#, 'field_id', 'access_ids'])
|
78
|
+
@global_context.merge!({}).merge!(@config[:global_context] || {})
|
79
|
+
models.each {|openerp_model| define_openerp_model(openerp_model, @config[:scope_prefix])}
|
73
80
|
end
|
74
|
-
models = @ir_model_class.read(model_ids, ['name', 'model', 'id', 'info', 'state', 'field_id', 'access_ids'])
|
75
|
-
@global_context.merge!({}).merge!(@config[:global_context] || {})
|
76
|
-
models.each {|openerp_model| define_openerp_model(openerp_model, @config[:scope_prefix])}
|
77
|
-
end
|
78
81
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
82
|
+
def define_openerp_model(param, scope_prefix=nil, url=nil, database=nil, user_id=nil, pass=nil)
|
83
|
+
klass = Class.new(OpenObjectResource)
|
84
|
+
klass.ooor = self
|
85
|
+
klass.site = url || @base_url
|
86
|
+
klass.user = user_id
|
87
|
+
klass.password = pass
|
88
|
+
klass.database = database
|
89
|
+
klass.openerp_model = param['model']
|
90
|
+
klass.openerp_id = url || param['id']
|
91
|
+
klass.info = (param['info'] || '').gsub("'",' ')
|
92
|
+
model_class_name = klass.class_name_from_model_key
|
93
|
+
klass.name = model_class_name
|
94
|
+
klass.state = param['state']
|
95
|
+
#klass.field_ids = param['field_id']
|
96
|
+
#klass.access_ids = param['access_ids']
|
97
|
+
klass.many2one_associations = {}
|
98
|
+
klass.one2many_associations = {}
|
99
|
+
klass.many2many_associations = {}
|
100
|
+
klass.polymorphic_m2o_associations = {}
|
101
|
+
klass.associations_keys = []
|
102
|
+
klass.fields = {}
|
103
|
+
klass.scope_prefix = scope_prefix
|
104
|
+
@logger.info "registering #{model_class_name} as an ActiveResource proxy for OpenObject #{param['model']} model"
|
105
|
+
(scope_prefix ? Object.const_get(scope_prefix) : Object).const_set(model_class_name, klass)
|
106
|
+
@loaded_models.push(klass)
|
107
|
+
klass
|
108
|
+
end
|
106
109
|
|
110
|
+
end
|
111
|
+
|
112
|
+
if defined?(Rails) #Optional autoload in Rails:
|
113
|
+
if Rails.version[0] == "3"[0] #Rails 3 bootstrap
|
114
|
+
class Railtie < Rails::Railtie
|
115
|
+
initializer "ooor.middleware" do |app|
|
116
|
+
Ooor.default_config = Ooor.load_config(false, RAILS_ENV)
|
117
|
+
Ooor.default_ooor = Ooor.new(Ooor.default_config) if Ooor.default_config['bootstrap']
|
118
|
+
end
|
119
|
+
end
|
120
|
+
else #Rails 2.3.x bootstrap
|
121
|
+
Ooor.default_config = Ooor.load_config(false, RAILS_ENV)
|
122
|
+
Ooor.default_ooor = Ooor.new(Ooor.default_config) if Ooor.default_config['bootstrap']
|
123
|
+
end
|
124
|
+
end
|
107
125
|
end
|
108
|
-
|
109
|
-
if defined?(Rails) #Optionnal autoload in Rails:
|
110
|
-
Ooor.default_config = Ooor.load_config(false, RAILS_ENV)
|
111
|
-
Ooor.default_ooor = Ooor.new(Ooor.default_config) if Ooor.default_config['bootstrap']
|
112
|
-
end
|