Sha256: c907e8cea9cc3a1937ece0b5fd86fc544354feab58a0e434f19a426daccc168d
Contents?: true
Size: 808 Bytes
Versions: 1
Compression:
Stored size: 808 Bytes
Contents
module Locomotive class SiteMetafieldsService < Struct.new(:site, :account) 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 site.save 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
locomotivecms-3.1.0.rc1 | app/services/locomotive/site_metafields_service.rb |