Class: Versacommerce::ThemeAPIClient::Resources::File
Instance Attribute Summary collapse
#new_record
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #name, #path=
#assign_attributes, #initialize, #new_record?, #save, #update
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
71
72
73
|
# File 'lib/versacommerce/theme_api_client/resources/file.rb', line 71
def content
@content
end
|
#stats ⇒ Object
Returns the value of attribute stats.
72
73
74
|
# File 'lib/versacommerce/theme_api_client/resources/file.rb', line 72
def stats
@stats
end
|
Class Method Details
.delete(path) ⇒ Object
31
32
33
34
|
# File 'lib/versacommerce/theme_api_client/resources/file.rb', line 31
def delete(path)
fetcher.delete(file_path(path))
true
end
|
.find(path, load_content: false) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/versacommerce/theme_api_client/resources/file.rb', line 22
def find(path, load_content: false)
response = fetcher.get(file_path(path))
attributes = response.json
new(attributes.merge(new_record: false)).tap do |file|
file.reload_content if load_content && !file.has_content?
end
end
|
.in_path(path = '', recursive = true) ⇒ Object
18
19
20
|
# File 'lib/versacommerce/theme_api_client/resources/file.rb', line 18
def in_path(path = '', recursive = true)
recursive ? fetch_recursive(path) : fetch_non_recursive(path)
end
|
.model_name ⇒ Object
36
37
38
|
# File 'lib/versacommerce/theme_api_client/resources/file.rb', line 36
def model_name
ActiveModel::Name.new(self, nil, 'File')
end
|
Instance Method Details
#delete ⇒ Object
74
75
76
77
78
79
80
|
# File 'lib/versacommerce/theme_api_client/resources/file.rb', line 74
def delete
unless new_record?
response = fetcher.delete(file_path(path))
content_will_change!
self.new_record = true
end
end
|
#has_content? ⇒ Boolean
89
90
91
|
# File 'lib/versacommerce/theme_api_client/resources/file.rb', line 89
def has_content?
!!@content
end
|
#inspect ⇒ Object
103
104
105
|
# File 'lib/versacommerce/theme_api_client/resources/file.rb', line 103
def inspect
'#<File:0x%x>' % (object_id << 1)
end
|
#reload_content ⇒ Object
93
94
95
96
97
98
99
100
101
|
# File 'lib/versacommerce/theme_api_client/resources/file.rb', line 93
def reload_content
unless new_record?
response = fetcher.get(download_path(path))
self.content = response.to_s
clear_attribute_changes(:content)
end
self
end
|