Class: Prestashop::Mapper::Model

Inherits:
Object
  • Object
show all
Extended by:
Extension
Includes:
Extension
Defined in:
lib/prestashop/mapper/model.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Extension

included

Class Method Details

.model(value = nil) ⇒ Object


32
33
34
# File 'lib/prestashop/mapper/model.rb', line 32

def model value = nil
  value.nil? ? @model : @model = value
end

.resource(value = nil) ⇒ Object


28
29
30
# File 'lib/prestashop/mapper/model.rb', line 28

def resource value = nil
  value.nil? ? @resource : @resource = value
end

Instance Method Details

#hash_lang(name, id_lang) ⇒ Object


23
24
25
# File 'lib/prestashop/mapper/model.rb', line 23

def hash_lang name, id_lang
  { language: { val: name, attr: { id: id_lang }}} if name
end

#meta_descriptionObject

Meta description is same as description, when is not given


14
15
16
# File 'lib/prestashop/mapper/model.rb', line 14

def meta_description
  @meta_description ? @meta_description.restricted.truncate(252) : ( description_short.plain if description_short )
end

#meta_keywordsObject

Meta keywords are generated from name, when are not given


19
20
21
# File 'lib/prestashop/mapper/model.rb', line 19

def meta_keywords
  @meta_keywords ? @meta_keywords.plain.truncate(61) : name.split(' ').join(', ')
end

#meta_titleObject

Meta title is same as name, when is not given


9
10
11
# File 'lib/prestashop/mapper/model.rb', line 9

def meta_title
  @meta_title ? @meta_title.plain.truncate(61) : name
end