Sha256: 284b3c97cdb49aeb1111d81b221b96305d06cb2a046515e926a28b52c9773484

Contents?: true

Size: 525 Bytes

Versions: 2

Compression:

Stored size: 525 Bytes

Contents

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(*::Shop.column_names))
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
disco_app-0.3.0 lib/generators/disco_app/templates/jobs/shop_update_job.rb
disco_app-0.4.0 lib/generators/disco_app/templates/jobs/shop_update_job.rb