Sha256: 30a1ad61fa5563edcd3493a6297ce01b5e1e4603e4feea78ae6a374fb06c4f73

Contents?: true

Size: 551 Bytes

Versions: 3

Compression:

Stored size: 551 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators'

module Rails
  class QueryGenerator < Rails::Generators::NamedBase

    source_root File.expand_path('../templates', __FILE__)
    check_class_collision suffix: 'Query'

    def copy_files
      path = File.join('app', 'queries', class_path, "#{file_name}_query.rb")
      template('query.rb.tt', path)
    end

    private

    def file_name
      @_file_name ||= remove_possible_suffix(super)
    end

    def remove_possible_suffix(name)
      name.sub(/_?query$/i, '')
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lite-query-1.1.0 lib/generators/rails/query_generator.rb
lite-query-1.0.8 lib/generators/rails/query_generator.rb
lite-query-1.0.7 lib/generators/rails/query_generator.rb