Class: ShopifyCLI::Theme::Syncer::Uploader::BulkItem

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_cli/theme/syncer/uploader/bulk_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, &block) ⇒ BulkItem

Returns a new instance of BulkItem.



13
14
15
16
17
# File 'lib/shopify_cli/theme/syncer/uploader/bulk_item.rb', line 13

def initialize(file, &block)
  @file = file
  @block = block
  @retries = 0
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



10
11
12
# File 'lib/shopify_cli/theme/syncer/uploader/bulk_item.rb', line 10

def block
  @block
end

#fileObject (readonly)

Returns the value of attribute file.



10
11
12
# File 'lib/shopify_cli/theme/syncer/uploader/bulk_item.rb', line 10

def file
  @file
end

#retriesObject

Returns the value of attribute retries.



11
12
13
# File 'lib/shopify_cli/theme/syncer/uploader/bulk_item.rb', line 11

def retries
  @retries
end

Instance Method Details

#assetObject



43
44
45
# File 'lib/shopify_cli/theme/syncer/uploader/bulk_item.rb', line 43

def asset
  @asset ||= asset_hash
end

#bodyObject



39
40
41
# File 'lib/shopify_cli/theme/syncer/uploader/bulk_item.rb', line 39

def body
  @body ||= JSON.generate(asset: asset)
end

#keyObject



31
32
33
# File 'lib/shopify_cli/theme/syncer/uploader/bulk_item.rb', line 31

def key
  file.relative_path
end

#liquid?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/shopify_cli/theme/syncer/uploader/bulk_item.rb', line 27

def liquid?
  file.liquid?
end

#sizeObject



35
36
37
# File 'lib/shopify_cli/theme/syncer/uploader/bulk_item.rb', line 35

def size
  @size ||= body.bytesize
end

#to_hObject



19
20
21
# File 'lib/shopify_cli/theme/syncer/uploader/bulk_item.rb', line 19

def to_h
  { body: body }
end

#to_sObject



23
24
25
# File 'lib/shopify_cli/theme/syncer/uploader/bulk_item.rb', line 23

def to_s
  "#<#{self.class.name} key=#{key}, retries=#{retries}>"
end