Sha256: 738196f89222c7288f27e71441728e069ba9b910ed6bda5a7b0c4ddd61b0d1f3

Contents?: true

Size: 817 Bytes

Versions: 36

Compression:

Stored size: 817 Bytes

Contents

# frozen_string_literal: true
require 'rails/generators'
require 'rails/generators/model_helpers'

class Valkyrie::ResourceGenerator < Rails::Generators::NamedBase
  # Include ModelHelpers to warn about pluralization when generating new models or scaffolds
  include Rails::Generators::ModelHelpers

  source_root File.expand_path('../templates', __FILE__)

  argument :attributes, type: :array, default: [], banner: 'field:type field:type'

  def create_model
    template('resource.rb.erb', File.join('app/models', class_path, "#{file_name}.rb"))
  end

  def create_model_spec
    return unless rspec_installed?
    template('resource_spec.rb.erb', File.join('spec/models', class_path, "#{file_name}_spec.rb"))
  end

  private

    def rspec_installed?
      defined?(RSpec) && defined?(RSpec::Rails)
    end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
valkyrie-2.1.1 lib/generators/valkyrie/resource_generator.rb
valkyrie-2.1.0 lib/generators/valkyrie/resource_generator.rb
valkyrie-2.0.2 lib/generators/valkyrie/resource_generator.rb
valkyrie-2.0.1 lib/generators/valkyrie/resource_generator.rb
valkyrie-2.0.0 lib/generators/valkyrie/resource_generator.rb
valkyrie-2.0.0.RC10 lib/generators/valkyrie/resource_generator.rb
valkyrie-2.0.0.RC9 lib/generators/valkyrie/resource_generator.rb
valkyrie-1.7.1 lib/generators/valkyrie/resource_generator.rb
valkyrie-2.0.0.RC8 lib/generators/valkyrie/resource_generator.rb
valkyrie-1.7.0 lib/generators/valkyrie/resource_generator.rb
valkyrie-2.0.0.RC7 lib/generators/valkyrie/resource_generator.rb
valkyrie-2.0.0.RC6 lib/generators/valkyrie/resource_generator.rb
valkyrie-2.0.0.RC5 lib/generators/valkyrie/resource_generator.rb
valkyrie-2.0.0.RC4 lib/generators/valkyrie/resource_generator.rb
valkyrie-1.6.0 lib/generators/valkyrie/resource_generator.rb
valkyrie-1.5.1 lib/generators/valkyrie/resource_generator.rb
valkyrie-2.0.0.RC3 lib/generators/valkyrie/resource_generator.rb
valkyrie-1.5.0 lib/generators/valkyrie/resource_generator.rb
valkyrie-1.5.0.RC2 lib/generators/valkyrie/resource_generator.rb
valkyrie-1.5.0.RC1 lib/generators/valkyrie/resource_generator.rb