Class: Effective::Generators::AbilityGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Effective::Generators::AbilityGenerator
- Includes:
- Helpers
- Defined in:
- lib/generators/effective/ability_generator.rb
Instance Method Summary collapse
Instance Method Details
#create_ability ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/effective/ability_generator.rb', line 26 def create_ability unless File.exist?(resource.abilities_file) say_status(:skipped, :ability, :yellow) and return end Effective::CodeWriter.new(resource.abilities_file) do |w| if w.find { |line, depth| (depth == 2 || depth == 3) && line == ability } say_status :identical, ability, :blue else w.insert_into_first(ability + "\n") { |line, depth| line.start_with?('def initialize') || line.end_with?('abilities(user)') } say_status :ability, ability end end end |
#invoke_ability ⇒ Object
22 23 24 |
# File 'lib/generators/effective/ability_generator.rb', line 22 def invoke_ability say_status :invoke, :ability, :white end |
#validate_resource ⇒ Object
18 19 20 |
# File 'lib/generators/effective/ability_generator.rb', line 18 def validate_resource exit unless resource_valid? end |