Sha256: 2c6a0eb977a9fc4eee2ba98f3734ed535554941b3a4d14a510603f9ef9cd3ea5

Contents?: true

Size: 632 Bytes

Versions: 25

Compression:

Stored size: 632 Bytes

Contents

module DiscoApp::Concerns::ShopUpdateJob
  extend ActiveSupport::Concern

  # Perform an update of the current shop's information.
  def perform(shopify_domain, shop_data = nil)
    # If we weren't provided with shop data (eg from a webhook), fetch it.
    shop_data ||= ActiveSupport::JSON::decode(ShopifyAPI::Shop.current.to_json)

    # Ensure we can access shop data through symbols.
    shop_data = HashWithIndifferentAccess.new(shop_data)

    # Update model attributes present in both our model and the data hash.
    @shop.update_attributes(shop_data.except(:id, :created_at).slice(*DiscoApp::Shop.column_names))
  end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
disco_app-0.6.1 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.6.2 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.6.3 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.6.4 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.6.5 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.6.6 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.6.7 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.6.8 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.6.9 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.7.0 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.7.1 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.7.2 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.8.0 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.8.1 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.8.2 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.8.3 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.8.4 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.8.5 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.8.6 app/jobs/disco_app/concerns/shop_update_job.rb
disco_app-0.8.7 app/jobs/disco_app/concerns/shop_update_job.rb