Class: RestaurantCpt::Cell::DefaultSeo
- Inherits:
-
Trailblazer::Cell
- Object
- Trailblazer::Cell
- RestaurantCpt::Cell::DefaultSeo
- Defined in:
- app/concepts/restaurant_cpt/cell/default_seo.rb
Overview
Responsible to manage restaurant default seo
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.generate_package_types(restaurant_id) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/concepts/restaurant_cpt/cell/default_seo.rb', line 19 def self.generate_package_types(restaurant_id) restaurant = Restaurant.fetch restaurant_id restaurant_packages = restaurant.restaurant_packages HhPackage::PACKAGE_LIST.each do |package_type| tag = RestaurantTag.send("tagged_as_#{HhPackage::PACKAGE_LIST_TO_SHORT[package_type.to_sym]}") if restaurant_packages.where(package_type: "HhPackage::Package::#{package_type}", active: true).present? begin unless tag.restaurants.include?(restaurant) tag.restaurants << restaurant end rescue ActiveRecord::RecordNotUnique # skip to next since it's already tagged next end elsif tag.restaurants.include?(restaurant) tag.restaurants.delete restaurant end end end |
Instance Method Details
#description ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/concepts/restaurant_cpt/cell/default_seo.rb', line 67 def description if seo.send("use_restaurant_misc_as_description_#{locale}".to_sym) strip(model.misc) elsif seo.send("use_site_description_as_description_#{locale}".to_sym) AdminSetting.with_lang('default_site_description', locale) elsif seo.description.present? strip(seo.description) else model.misc end end |
#keywords ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'app/concepts/restaurant_cpt/cell/default_seo.rb', line 79 def keywords if seo.send("use_site_keywords_as_keywords_#{locale}".to_sym) AdminSetting.with_lang('default_site_keywords', locale) elsif seo.keywords.present? seo.keywords else model.name(for_api: true) end end |
#show ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/concepts/restaurant_cpt/cell/default_seo.rb', line 40 def show MyLocaleManager.available_locales.each do |l| I18n.with_locale(l) do if main_package_type.nil? setup_seo_for_inactive_restaurant(seo, l) else setup_seo_for_active_restaurant(seo, l) end end end seo rescue StandardError => e APMErrorHandler.report('Unable to setup restaurant SEO', e: e) raise(e) end |
#title ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'app/concepts/restaurant_cpt/cell/default_seo.rb', line 57 def title if seo.send("use_restaurant_name_as_title_#{locale}".to_sym) model.name(for_api: true) elsif seo.title.present? seo.title else model.name(for_api: true) end end |