Class: Recipes::Draper

Inherits:
Rails::AppBuilder
  • Object
show all
Defined in:
lib/potassium/recipes/draper.rb

Instance Method Summary collapse

Instance Method Details

#add_api_responderObject



29
30
31
32
33
# File 'lib/potassium/recipes/draper.rb', line 29

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

#add_draperObject



23
24
25
26
27
# File 'lib/potassium/recipes/draper.rb', line 23

def add_draper
  gather_gem 'draper', '3.0.0.pre1'
  add_readme_section :internal_dependencies, :draper
  create_file 'app/decorators/.keep'
end

#askObject



2
3
4
5
# File 'lib/potassium/recipes/draper.rb', line 2

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

#createObject



7
8
9
10
11
# File 'lib/potassium/recipes/draper.rb', line 7

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

#installObject



17
18
19
20
21
# File 'lib/potassium/recipes/draper.rb', line 17

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

#installed?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/potassium/recipes/draper.rb', line 13

def installed?
  gem_exists?(/draper/)
end