lib/generators/effective/ability_generator.rb in effective_developer-0.0.10 vs lib/generators/effective/ability_generator.rb in effective_developer-0.1.1

- old
+ new

@@ -19,11 +19,11 @@ say_status :invoke, :ability, :white end def create_ability Effective::CodeWriter.new('app/models/ability.rb') do |w| - if namespaces.blank? + if resource.namespaces.blank? if w.find { |line, depth| depth == 2 && line == ability } say_status :identical, ability, :blue else w.insert_after_last(ability) { |line, depth| depth == 2 && line.start_with?('can ') } || w.insert_before_last(ability) { |line, depth| depth == 2 && line.start_with?('if') } || @@ -31,11 +31,11 @@ say_status :ability, ability end end - namespaces.each do |namespace| + resource.namespaces.each do |namespace| w.within("if user.is?(:#{namespace})") do if w.find { |line, depth| depth == 1 && line == ability } say_status :identical, ability, :blue else w.insert_after_last(ability) { |line, depth| depth == 1 && line.start_with?('can ') } || @@ -68,10 +68,10 @@ abilities = ":#{abilities.first}" else abilities = '[' + abilities.map { |action| ':' + action }.join(', ') + ']' end - "can #{abilities}, #{class_name}" + "can #{abilities}, #{resource.class_name}" ) end end end end