Module: ModelExt::Restaurants::ImenuPro

Included in:
Restaurant
Defined in:
lib/model_ext/restaurants/imenu_pro.rb

Overview

Responsible for IMenu Pro integration for Restaurant model

Instance Method Summary collapse

Instance Method Details



6
7
8
9
# File 'lib/model_ext/restaurants/imenu_pro.rb', line 6

def imenu_pro_link
  note = ::GenericNote.fetch_by_parent_id_and_parent_type id, self.class.to_s
  note.try(:imenu_pro_links) || []
end

#imenu_pro_link=(links) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/model_ext/restaurants/imenu_pro.rb', line 11

def imenu_pro_link=(links)
  note = ::GenericNote.find_or_initialize_by(parent_id: id,
                                             parent_type: self.class.to_s)

  note.imenu_pro_links = links.strip.split(',').map(&:strip)
  unless note.save
    errors.add(:base, note.errors.full_messages.to_sentence)
  end
  note
end