Method: Stay::ControllerHelpers::Store#ensure_current_store
- Defined in:
- lib/stay/controller_helpers/store.rb
#ensure_current_store(object) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/stay/controller_helpers/store.rb', line 22 def ensure_current_store(object) return if object.nil? if object.has_attribute?(:store_id) if object.store.present? && object.store != current_store raise I18n.t('errors.messages.store_is_already_set') else object.store = current_store end elsif object.class.method_defined?(:stores) && object.stores.exclude?(current_store) object.stores << current_store end end |