Skip to content

Instantly share code, notes, and snippets.

@jonathanpa
Created September 28, 2017 19:26
Show Gist options
  • Select an option

  • Save jonathanpa/f3daeee05b0154aa1cda507841f869cb to your computer and use it in GitHub Desktop.

Select an option

Save jonathanpa/f3daeee05b0154aa1cda507841f869cb to your computer and use it in GitHub Desktop.

Revisions

  1. jonathanpa created this gist Sep 28, 2017.
    16 changes: 16 additions & 0 deletions entity_keys.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    entity_class = "#{ARGV[0]}Entity".constantize
    model_class = "#{ARGV[0]}".constantize

    output_path =
    Rails.root.join('spec', 'fixtures', 'entities', "#{ARGV[0].underscore}.yml")

    File.open(output_path, 'w') do |file|
    file.write(
    entity_class
    .represent(model_class.new)
    .serializable_hash
    .keys
    .map(&:to_s)
    .to_yaml
    )
    end