-
Notifications
You must be signed in to change notification settings - Fork 900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export by safer element's filename or id #19702
Changes from all commits
5bc8971
4a74832
9ce816e
cfb27b1
c63b4d9
5657291
b0cf105
4b0afa0
5c9d252
51e6c33
28bd713
f4a5c1c
86c4b0e
a3c32b1
cb01e28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module TaskHelpers | ||
class Exports | ||
class CustomizationTemplates | ||
EXCLUDE_ATTRS = %i(created_at updated_at id pxe_image_type_id class).freeze | ||
EXCLUDE_ATTRS = %i(created_at updated_at pxe_image_type_id).freeze | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change makes me think that this maybe isn't the right way to do this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you elaborate your thoughts? Whats the point in removing these attributes anyway? You can still throw them away while importing. |
||
def export(options = {}) | ||
export_dir = options[:directory] | ||
|
||
|
@@ -13,8 +13,7 @@ def export(options = {}) | |
ct_hash = Exports.exclude_attributes(customization_template.to_model_hash, EXCLUDE_ATTRS) | ||
ct_hash.merge!(pxe_image_type_hash(customization_template.pxe_image_type)) | ||
|
||
image_type_name = ct_hash.fetch_path(:pxe_image_type, :name) || "Examples" | ||
filename = Exports.safe_filename("#{image_type_name}-#{ct_hash[:name]}", options[:keep_spaces]) | ||
filename = Exports.safe_filename(ct_hash, options[:keep_spaces], options[:super_safe_filename]) | ||
File.write("#{export_dir}/#{filename}.yaml", ct_hash.to_yaml) | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we tend to prefer
is_a?
orkind_of?