Class: Openbeautyfacts::Product

Inherits:
Openfoodfacts::Product
  • Object
show all
Defined in:
lib/openbeautyfacts/product.rb

Constant Summary collapse

DEFAULT_LOCALE =

Override constants for openbeautyfacts domain

Locale::GLOBAL
DEFAULT_DOMAIN =
'openbeautyfacts.org'
LOCALE_WEBURL_PREFIXES =

OpenBeautyFacts uses the same URL prefixes as OpenFoodFacts

{
  'fr' => 'produit',
  'uk' => 'product',
  'us' => 'product',
  'world' => 'product'
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.search(terms, locale: DEFAULT_LOCALE, page: 1, page_size: 20, sort_by: 'unique_scans_n', domain: DEFAULT_DOMAIN) ⇒ Object

Override search method to use openbeautyfacts domain



24
25
26
27
# File 'lib/openbeautyfacts/product.rb', line 24

def search(terms, locale: DEFAULT_LOCALE, page: 1, page_size: 20, sort_by: 'unique_scans_n',
           domain: DEFAULT_DOMAIN)
  super(terms, locale: locale, page: page, page_size: page_size, sort_by: sort_by, domain: domain)
end

.url(code, locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN) ⇒ Object

Override URL method to use openbeautyfacts domain



19
20
21
# File 'lib/openbeautyfacts/product.rb', line 19

def url(code, locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
  super(code, locale: locale, domain: domain)
end

Instance Method Details

#update(user: nil, domain: DEFAULT_DOMAIN) ⇒ Object

Override update method to use openbeautyfacts domain



36
37
38
# File 'lib/openbeautyfacts/product.rb', line 36

def update(user: nil, domain: DEFAULT_DOMAIN)
  super(user: user, domain: domain)
end

#weburl(locale: nil, domain: DEFAULT_DOMAIN) ⇒ Object

Override weburl method to use openbeautyfacts domain



31
32
33
# File 'lib/openbeautyfacts/product.rb', line 31

def weburl(locale: nil, domain: DEFAULT_DOMAIN)
  super(locale: locale, domain: domain)
end