Sha256: d9cbe52b6aa3fccab914a27793a2c0e53550196f53ca3a00572717173b355824

Contents?: true

Size: 658 Bytes

Versions: 2

Compression:

Stored size: 658 Bytes

Contents

require 'rails/generators'

module Hancock::Gallery::Models
  class DecoratorsGenerator < Rails::Generators::Base
    source_root File.expand_path('../../../../../../app/models/concerns/hancock/gallery/decorators', __FILE__)
    argument :models, type: :array, default: []

    desc 'Hancock::Gallery Models decorators generator'
    def decorators
      (models == ['all'] ? permitted_models : models & permitted_models).each do |m|
        copy_file "#{m}.rb", "app/models/concerns/hancock/gallery/decorators/#{m}.rb"
      end
    end

    private
    def permitted_models
      ['embedded_image', 'gallery', 'image', 'original_image']
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hancock_cms_gallery-1.0.2 lib/generators/hancock/gallery/models/decorators_generator.rb
hancock_cms_gallery-1.0.0 lib/generators/hancock/gallery/models/decorators_generator.rb