Class: BitrixOnRails::IblockElementPropS::MPropValuesWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/bitrix_on_rails/iblock_element_prop_s.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(iblock_element_id, iblock_property_id, m_prop_class) ⇒ MPropValuesWrapper

Returns a new instance of MPropValuesWrapper.



7
8
9
10
11
12
# File 'lib/bitrix_on_rails/iblock_element_prop_s.rb', line 7

def initialize(iblock_element_id, iblock_property_id, m_prop_class)
  @iblock_element_id = iblock_element_id
  @iblock_property_id = iblock_property_id

  @m_prop_class = m_prop_class
end

Instance Attribute Details

#iblock_element_idObject (readonly)

Returns the value of attribute iblock_element_id.



5
6
7
# File 'lib/bitrix_on_rails/iblock_element_prop_s.rb', line 5

def iblock_element_id
  @iblock_element_id
end

#iblock_property_idObject (readonly)

Returns the value of attribute iblock_property_id.



5
6
7
# File 'lib/bitrix_on_rails/iblock_element_prop_s.rb', line 5

def iblock_property_id
  @iblock_property_id
end

Instance Method Details

#add(value) ⇒ Object



21
22
23
24
25
26
# File 'lib/bitrix_on_rails/iblock_element_prop_s.rb', line 21

def add(value)
  @m_prop_class.create(
    :iblock_element_id => @iblock_element_id,
    :iblock_property_id => @iblock_property_id,
    :value => value)
end

#remove(value) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/bitrix_on_rails/iblock_element_prop_s.rb', line 28

def remove(value)
  m_props = @m_prop_class.where(
    :iblock_element_id => @iblock_element_id,
    :iblock_property_id => @iblock_property_id,
    :value => value)
  m_props.each { |p| p.destroy } if m_props.any?
end

#valuesObject



14
15
16
17
18
19
# File 'lib/bitrix_on_rails/iblock_element_prop_s.rb', line 14

def values
  @m_prop_class.where(
    :iblock_element_id => @iblock_element_id,
    :iblock_property_id => @iblock_property_id
  ).collect { |e| e.value }
end