Sha256: 695d3069c96ab731f5adcae2d29d33ba7a55c63686bea2e7342ec9a403da0493
Contents?: true
Size: 809 Bytes
Versions: 1
Compression:
Stored size: 809 Bytes
Contents
# frozen_string_literal: true require 'rails/generators' module Rails class DecoratorGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) check_class_collision suffix: 'Decorator' def copy_files path = File.join('app', 'decorators', class_path, "#{file_name}_decorator.rb") empty_directory('app/decorators') template('decorator.rb.tt', path) end def copy_specs path = File.join('spec', 'decorators', class_path, "#{file_name}_decorator_spec.rb") empty_directory('spec/decorators') template('spec.rb.tt', path) end private def file_name @_file_name ||= remove_possible_suffix(super) end def remove_possible_suffix(name) name.sub(/_?decorator$/i, '') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lite-decorator-1.0.1 | lib/generators/rails/decorator_generator.rb |