Sha256: f53982d0c621b55fd51a728aab505c65f81f0f54003adeb07d3b39d8ea76ddbe

Contents?: true

Size: 501 Bytes

Versions: 29

Compression:

Stored size: 501 Bytes

Contents

module ShopifyAPI
  module Metafields
    def metafields(**options)
      options.merge! resource: self.class.collection_name, resource_id: id

      Metafield.find :all, params: options
    end

    def add_metafield(metafield)
      raise ArgumentError, "You can only add metafields to resource that has been saved" if new?

      metafield.prefix_options = {
        :resource => self.class.collection_name,
        :resource_id => id
      }
      metafield.save
      metafield
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
shopify_api-9.2.0 lib/shopify_api/metafields.rb
shopify_api-9.1.0 lib/shopify_api/metafields.rb
shopify_api-9.0.4 lib/shopify_api/metafields.rb
shopify_api-9.0.3 lib/shopify_api/metafields.rb
shopify_api-9.0.2 lib/shopify_api/metafields.rb
shopify_api-9.0.1 lib/shopify_api/metafields.rb
shopify_api-9.0.0 lib/shopify_api/metafields.rb
shopify_api-8.1.0 lib/shopify_api/metafields.rb
shopify_api-8.0.0 lib/shopify_api/metafields.rb
shopify_api-7.1.0 lib/shopify_api/metafields.rb
shopify_api-7.0.2 lib/shopify_api/metafields.rb
shopify_api-7.0.1 lib/shopify_api/metafields.rb
shopify_api-7.0.0 lib/shopify_api/metafields.rb
shopify_api-6.0.0 lib/shopify_api/metafields.rb
shopify_api-5.2.4 lib/shopify_api/metafields.rb
shopify_api-5.2.3 lib/shopify_api/metafields.rb
shopify_api-5.2.2 lib/shopify_api/metafields.rb
shopify_api-5.2.1 lib/shopify_api/metafields.rb
shopify_api-5.2.0 lib/shopify_api/metafields.rb
shopify_api-5.1.0 lib/shopify_api/metafields.rb