Sha256: 6cd1ae0ef3377562029602a87494962dea7d1322b8289385a3b354d1636d6b21

Contents?: true

Size: 837 Bytes

Versions: 75

Compression:

Stored size: 837 Bytes

Contents

# frozen_string_literal: true
require 'rails/generators'

module Blacklight
  class SearchBuilderGenerator < Rails::Generators::Base
    include Rails::Generators::Migration

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

    argument :model_name, type: :string, default: "search_builder"

    desc <<-EOS
    This generator makes the following changes to your application:
     1. Creates a blacklight search builder in your /app/models directory
    EOS
    def create_search_builder
      template "search_builder.rb", "app/models/#{model_name}.rb"
    end

    def create_search_builder_spec
      return unless rspec_installed?

      template "search_builder_spec.rb", "spec/models/#{model_name}_spec.rb"
    end

    private

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

Version data entries

75 entries across 75 versions & 2 rubygems

Version Path
blacklight-7.40.0 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.39.0 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.38.0 lib/generators/blacklight/search_builder_generator.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/lib/generators/blacklight/search_builder_generator.rb
blacklight-7.37.0 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.36.2 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.36.1 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.36.0 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.35.0 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.34.0 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.33.1 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.33.0 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.32.0 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.31.0 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.30.0 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.29.0 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.28.0 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.27.1 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.27.0 lib/generators/blacklight/search_builder_generator.rb
blacklight-7.26.1 lib/generators/blacklight/search_builder_generator.rb