Sha256: e3010853d23c81b605b9fb49dabb9137e153f246dfa44a0dd181424238c7b53a

Contents?: true

Size: 731 Bytes

Versions: 2

Compression:

Stored size: 731 Bytes

Contents

class <%= model_name %>Generator < ::Rails::Generators::NamedBase
  source_root File.expand_path("../templates", __FILE__)
  desc "Creates a new <%= model_name %>"

  def generate_view
    template "app/views/#{directory}/content/#{file_name}.md", 'view.md.erb'
  end

  private
  def date
    @date_string ||= Time.now.strftime '%Y-%m-%d'
  end

  def title
    @title ||= param_name.titleize.downcase
  end

  def table_name
    human_name.tableize
  end

  def param_name
    human_name.parameterize
  end

  def file_name
  <% if datestamped? %>
    "#{date}-#{param_name}"
  <% else %>
    param_name
  <% end %>
  end

  def attributes_yaml
    attributes.reduce "" do |yaml, key|
      yaml << "#{key}: \n"
    end
  end
nd

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_copy-1.0.0 lib/generators/copy/templates/generator.rb.erb
active_copy-1.0.0.pre lib/generators/copy/templates/generator.rb.erb