Sha256: bfb0a64b16a0b68f0d6aad090f617f7322528a6f31ca5ae9029a918a58f854d4
Contents?: true
Size: 921 Bytes
Versions: 28
Compression:
Stored size: 921 Bytes
Contents
module Locomotive class SiteMetafieldsService < Struct.new(:site, :account) include Locomotive::Concerns::ActivityService def update_all(attributes) each_metafield(attributes) do |namespace, name, value| next unless field = site.find_metafield(name) if field['localized'] (namespace[name] ||= {})[locale] = value else namespace[name] = value end end if site.save track_activity 'site_metafields.updated' end end protected def each_metafield(attributes, &block) return if attributes.blank? attributes.each do |_name, _attributes| site.metafields[_name] ||= {} namespace = site.metafields[_name] _attributes.each do |name, value| yield(namespace, name, value) end end end def locale ::Mongoid::Fields::I18n.locale end end end
Version data entries
28 entries across 28 versions & 1 rubygems