Class: ForgeCLI::AbilityInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/forge-cli/ability_installer.rb

Class Method Summary collapse

Class Method Details

.ability_fileObject



15
16
17
# File 'lib/forge-cli/ability_installer.rb', line 15

def ability_file
  File.join(@app, 'app', 'models', 'ability.rb')
end

.ability_invocationObject



19
20
21
# File 'lib/forge-cli/ability_installer.rb', line 19

def ability_invocation
  "#{@ability_class}.new(u)"
end

.install_abilities!(app, ability_class) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/forge-cli/ability_installer.rb', line 3

def install_abilities!(app, ability_class)
  @app = app
  @ability_class = ability_class
  new_content = File.read(ability_file).gsub(
    /  end\nend\z/,
    "    #{ability_invocation}\n  end\nend"
  )
  File.open(ability_file, "w") do |f|
    f.puts new_content
  end
end