Sha256: bdc9ec446ee4e227a9f70a0a33bed4bbb04bf06379261c7aac1a46421e1ef498
Contents?: true
Size: 988 Bytes
Versions: 17
Compression:
Stored size: 988 Bytes
Contents
class ComponentGenerator < Rails::Generators::NamedBase source_root File.expand_path('templates', __dir__) def add_component segments = name.underscore.split('/') fail("NAME must be of the form Family::ComponentName or family/component_name but got #{name.inspect}") if segments.size != 2 @family, @comp = segments @family = @family.pluralize # Force plural @family_cst = @family.camelize.pluralize # Force plural @comp_cst = @comp.camelize # Tolerate singular and plural @args = args case @comp_cst when 'Destroy' template 'destroy.rb.erb', "app/components/#{@family}/#{@comp}.rb" when 'Edit' template 'edit.rb.erb', "app/components/#{@family}/#{@comp}.rb" when 'Form' template 'form.rb.erb', "app/components/#{@family}/#{@comp}.rb" when 'New' template 'new.rb.erb', "app/components/#{@family}/#{@comp}.rb" else template 'component.rb.erb', "app/components/#{@family}/#{@comp}.rb" end end end
Version data entries
17 entries across 17 versions & 1 rubygems