Module: BitrixOnRails
- Defined in:
- lib/bitrix_on_rails.rb,
lib/bitrix_on_rails/engine.rb,
lib/bitrix_on_rails/active_record.rb,
lib/bitrix_on_rails/configuration.rb,
lib/bitrix_on_rails/iblock_element.rb
Defined Under Namespace
Modules: ActiveRecord, IblockElementPropM, IblockElementPropS
Classes: Configuration, Engine
Constant Summary
collapse
- @@infoblocks =
Хранит список созданных классов в виде хеша: iblock_id -> class_name
{}
Class Method Summary
collapse
Class Method Details
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/bitrix_on_rails.rb', line 7
def self.configure
return unless ::ActiveRecord::Base.connection.tables.include? 'b_iblock'
config = Configuration.new
yield config
config.infoblocks.each { |infoblock|
BitrixOnRails.define_iblock_class(infoblock[:iblock_id], infoblock[:options])
}
end
|
.define_iblock_class(iblock_id, options = {}) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/bitrix_on_rails/iblock_element.rb', line 10
def self.define_iblock_class(iblock_id, options = {})
iblock_version = Iblock.find(iblock_id).version
iblock_element_class = send("create_iblock_v#{iblock_version}_class", iblock_id, options[:extended_class], options[:extended_by])
unless options[:extended_class]
if class_name = options[:class_name]
a = class_name.split('::')
class_name = a.last
namespace = a[0..-2].join('::')
namespace = namespace.empty? ? Object : Object.const_get(namespace)
else
class_name = "IblockElement#{iblock_id}"
namespace = Object
end
namespace.const_set(class_name, iblock_element_class)
end
create_prop_classes(iblock_id, iblock_element_class) if iblock_version == 2
iblock_element_class
end
|
.infoblocks ⇒ Object
6
7
8
|
# File 'lib/bitrix_on_rails/iblock_element.rb', line 6
def self.infoblocks
@@infoblocks
end
|