Class: Locomotive::SiteMetafieldsService

Inherits:
Struct
  • Object
show all
Includes:
Concerns::ActivityService
Defined in:
app/services/locomotive/site_metafields_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Concerns::ActivityService

#track_activity, #without_tracking_activity

Instance Attribute Details

#accountObject

Returns the value of attribute account

Returns:

  • (Object)

    the current value of account



3
4
5
# File 'app/services/locomotive/site_metafields_service.rb', line 3

def 
  @account
end

#siteObject

Returns the value of attribute site

Returns:

  • (Object)

    the current value of site



3
4
5
# File 'app/services/locomotive/site_metafields_service.rb', line 3

def site
  @site
end

Instance Method Details

#update_all(attributes) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/locomotive/site_metafields_service.rb', line 7

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