class Prestashop::Mapper::Supplier
Attributes
active[RW]
description[RW]
id[RW]
id_lang[RW]
link_rewrite[RW]
meta_description[RW]
meta_keywords[RW]
meta_title[RW]
name[RW]
Public Class Methods
new(args = {})
click to toggle source
# 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
Public Instance Methods
find_or_create()
click to toggle source
Find or create supplier from hash
# 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()
click to toggle source
Hash is used as default source for create
# File lib/prestashop/mapper/models/supplier.rb, line 27 def hash validate! { active: active, name: name } end
validate!()
click to toggle source
Supplier
must have 1/0 as active and name must be string
# 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