Sha256: 8d96a164f4382370b0845086cd96676d9a1bd767266ffd7e7483dcca6c991d3f

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 Bytes

Contents

class Recipes::Draper < Rails::AppBuilder
  def ask
    draper = answer(:draper) { Ask.confirm('Do you want to use Draper to decorate models?') }
    set(:draper, draper)
  end

  def create
    return unless selected?(:draper)
    add_draper
    add_api_responder if selected?(:api_support)
  end

  def installed?
    gem_exists?(/draper/)
  end

  def install
    add_draper
    api_recipe = load_recipe(:api)
    add_api_responder if api_recipe.installed?
  end

  def add_draper
    gather_gem 'activemodel-serializers-xml', github: 'rails/activemodel-serializers-xml'
    gather_gem 'draper'
    add_readme_section :internal_dependencies, :draper
    create_file 'app/decorators/.keep'
  end

  def add_api_responder
    after(:gem_install) do
      copy_file '../assets/api/draper_responder.rb', 'app/responders/api_responder.rb', force: true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
potassium-3.0.0 lib/potassium/recipes/draper.rb