Class: Prestashop::Mapper::Supplier
- Defined in:
- lib/prestashop/mapper/models/supplier.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#id_lang ⇒ Object
Returns the value of attribute id_lang.
-
#link_rewrite ⇒ Object
Returns the value of attribute link_rewrite.
-
#meta_description ⇒ Object
Returns the value of attribute meta_description.
-
#meta_keywords ⇒ Object
Returns the value of attribute meta_keywords.
-
#meta_title ⇒ Object
Returns the value of attribute meta_title.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#find_or_create ⇒ Object
Find or create supplier from hash.
-
#hash ⇒ Object
Hash is used as default source for #create.
-
#initialize(args = {}) ⇒ Supplier
constructor
A new instance of Supplier.
-
#validate! ⇒ Object
Supplier must have 1/0 as active and name must be string.
Methods inherited from Model
Methods included from Extension
Constructor Details
#initialize(args = {}) ⇒ Supplier
Returns a new instance of Supplier.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/prestashop/mapper/models/supplier.rb', line 11 def initialize args = {} @id = args[:id] @link_rewrite = args[:link_rewrite] @name = args.fetch(:name) @active = args.fetch(:active, 1) # date_add # date_upd @description = args[:description] @meta_title = args[:meta_title] @meta_description = args[:meta_description] @meta_keywords = args[:meta_keywords] @id_lang = args[:id_lang] end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
8 9 10 |
# File 'lib/prestashop/mapper/models/supplier.rb', line 8 def active @active end |
#description ⇒ Object
Returns the value of attribute description.
8 9 10 |
# File 'lib/prestashop/mapper/models/supplier.rb', line 8 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/prestashop/mapper/models/supplier.rb', line 8 def id @id end |
#id_lang ⇒ Object
Returns the value of attribute id_lang.
9 10 11 |
# File 'lib/prestashop/mapper/models/supplier.rb', line 9 def id_lang @id_lang end |
#link_rewrite ⇒ Object
Returns the value of attribute link_rewrite.
8 9 10 |
# File 'lib/prestashop/mapper/models/supplier.rb', line 8 def link_rewrite @link_rewrite end |
#meta_description ⇒ Object
Returns the value of attribute meta_description.
8 9 10 |
# File 'lib/prestashop/mapper/models/supplier.rb', line 8 def @meta_description end |
#meta_keywords ⇒ Object
Returns the value of attribute meta_keywords.
8 9 10 |
# File 'lib/prestashop/mapper/models/supplier.rb', line 8 def @meta_keywords end |
#meta_title ⇒ Object
Returns the value of attribute meta_title.
8 9 10 |
# File 'lib/prestashop/mapper/models/supplier.rb', line 8 def @meta_title end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/prestashop/mapper/models/supplier.rb', line 8 def name @name end |
Instance Method Details
#find_or_create ⇒ Object
Find or create supplier from hash
33 34 35 36 |
# File 'lib/prestashop/mapper/models/supplier.rb', line 33 def find_or_create supplier = self.class.find_by 'filter[name]' => name supplier ? supplier : create[:id] end |
#hash ⇒ Object
Hash is used as default source for #create
27 28 29 30 |
# File 'lib/prestashop/mapper/models/supplier.rb', line 27 def hash validate! { active: active, name: name } end |
#validate! ⇒ Object
Supplier must have 1/0 as active and name must be string
39 40 41 42 |
# File 'lib/prestashop/mapper/models/supplier.rb', line 39 def validate! raise ArgumentError, 'active must be 0 or 1' unless active == 0 or active == 1 raise ArgumentError, 'name must string' unless name.kind_of?(String) end |