Sha256: afb2a276a61141c8f46eee0e2817cd112b49d0aabe22de6da7a1953b765ffb82

Contents?: true

Size: 527 Bytes

Versions: 10

Compression:

Stored size: 527 Bytes

Contents

class Puffer::ControllerGenerator < Rails::Generators::NamedBase
  source_root File.expand_path('../templates', __FILE__)

  def generate_controller
    @modules = name.classify.split('::')
    @model_name = @modules.delete_at(-1)

    template('controller.rb', "app/controllers/#{controller_name.underscore}_controller.rb")
  end

private

  def controller_name
    [(swallow_nil{@modules.first} || 'Admin'), @model_name.pluralize].join('::')
  end

  def attributes
    @model_name.constantize.columns.map(&:name)
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
puffer-0.0.15 lib/generators/puffer/controller/controller_generator.rb
puffer-0.0.14 lib/generators/puffer/controller/controller_generator.rb
puffer-0.0.13 lib/generators/puffer/controller/controller_generator.rb
puffer-0.0.12 lib/generators/puffer/controller/controller_generator.rb
puffer-0.0.11 lib/generators/puffer/controller/controller_generator.rb
puffer-0.0.10 lib/generators/puffer/controller/controller_generator.rb
puffer-0.0.9 lib/generators/puffer/controller/controller_generator.rb
puffer-0.0.8 lib/generators/puffer/controller/controller_generator.rb
puffer-0.0.7 lib/generators/puffer/controller/controller_generator.rb
puffer-0.0.6 lib/generators/puffer/controller/controller_generator.rb