Sha256: d807aebb09f921d30373aa170600f7e11e422c60535ed57273b12c37e95f923b

Contents?: true

Size: 801 Bytes

Versions: 1

Compression:

Stored size: 801 Bytes

Contents

require 'rails/generators'

module Hancock::Search::Controllers
  class DecoratorsGenerator < Rails::Generators::Base
    source_root File.expand_path('../../../../../../app/controllers/concerns/hancock/search/decorators', __FILE__)
    argument :controllers, type: :array, default: []

    desc 'Hancock::Search Controllers generator'
    def decorators
      copied = false
      (controllers == ['all'] ? permitted_controllers : controllers & permitted_controllers).each do |c|
        copied = true
        copy_file "#{c}.rb", "app/controllers/concerns/hancock/search/decorators/#{c}.rb"
      end
      puts "U need to set controllers`s name. One of this: #{permitted_controllers.join(", ")}." unless copied
    end

    private
    def permitted_controllers
      ['search']
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hancock_cms_search-1.0.2 lib/generators/hancock/search/controllers/decorators_generator.rb