Class: EPlat::Woocommerce::Metafield
- Inherits:
-
Metafield
- Object
- Metafield
- EPlat::Woocommerce::Metafield
- Defined in:
- lib/e_plat/resource/platform_specific/woocommerce/metafield.rb
Instance Attribute Summary collapse
-
#order ⇒ Object
Returns the value of attribute order.
-
#product ⇒ Object
Returns the value of attribute product.
-
#variant ⇒ Object
Returns the value of attribute variant.
Instance Method Summary collapse
Instance Attribute Details
#order ⇒ Object
Returns the value of attribute order.
11 12 13 |
# File 'lib/e_plat/resource/platform_specific/woocommerce/metafield.rb', line 11 def order @order end |
#product ⇒ Object
Returns the value of attribute product.
11 12 13 |
# File 'lib/e_plat/resource/platform_specific/woocommerce/metafield.rb', line 11 def product @product end |
#variant ⇒ Object
Returns the value of attribute variant.
11 12 13 |
# File 'lib/e_plat/resource/platform_specific/woocommerce/metafield.rb', line 11 def variant @variant end |
Instance Method Details
#destroy ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/e_plat/resource/platform_specific/woocommerce/metafield.rb', line 13 def destroy return unless owner.present? run_callbacks :destroy do owner..each do |m| next unless m.id == id m.value = nil m.attribute_will_change!("id") m.attribute_will_change!("value") m.attribute_will_change!("key") end owner.attribute_will_change!("metafields") owner.save self.destroyed = true end end |
#owner ⇒ Object
32 33 34 |
# File 'lib/e_plat/resource/platform_specific/woocommerce/metafield.rb', line 32 def owner product || order || variant end |
#owner=(owner) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/e_plat/resource/platform_specific/woocommerce/metafield.rb', line 36 def owner=(owner) return if owner.nil? case owner.class.name when "EPlat::Woocommerce::Product" @product = owner when "EPlat::Woocommerce::Order" @order = owner when "EPlat::Woocommerce::Product::Variant" @variant = owner end end |