Sha256: 0d1bb6a4c2e1a6728fa07f7811ebfb07e4f7765b48fc3bd99501299d76f3bebf

Contents?: true

Size: 720 Bytes

Versions: 1

Compression:

Stored size: 720 Bytes

Contents

module Nrb
  module Commands
    class Generate < Commands::Resource
      desc "Generate a resource (#{valid_resources.join(', ')})."

      def generate_resource
        template "templates/#{resource}.rb.tt", target("#{name.underscore}.rb"),
          opts.merge({ name: name.camelize })
      end

      def generate_table
        return false unless resource == 'model'

        migration_name = "create_#{name.underscore.pluralize}"
        rake_options   = args.join(' ')

        inside Nrb.root, opts do
          Nrb.silently(opts) do
            run "bundle exec rake db:new_migration name=#{migration_name} options='#{rake_options}'",
              opts
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nrb-1.1.0 lib/nrb/commands/generate.rb