Sha256: 80ecd2206e0c57f70c9595878ca56d9731024604b855c50df562ceb1a40351e5

Contents?: true

Size: 574 Bytes

Versions: 1

Compression:

Stored size: 574 Bytes

Contents

module DiscoApp
  class ShopUpdateJob < DiscoApp::ShopJob

    def perform(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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
disco_app-0.6.0 app/jobs/disco_app/shop_update_job.rb