Sha256: 9a25778c98647b5d5f9480cbf5faea03e102a4b58f7202896cc77e0ea5fc0e48

Contents?: true

Size: 856 Bytes

Versions: 4

Compression:

Stored size: 856 Bytes

Contents

module Chatroom
	# Include this module in your generator to generate Chatroom views.
	# 'copy_views' is the main method and by default copies all views.
	module ViewPathTemplates

		def self.included(base)
			base.extend ClassMethods
		end

		module ClassMethods
			def hide!
				Rails::Generators.hide_namespace self.namespace
			end
		end

		protected
			def target_path
				@target_path ||= "app/views/chatroom"
			end

      def view_directory(name, _target_path = nil)
        directory name.to_s, _target_path || "#{target_path}/#{name}" do |content|
					content
				end
			end
	end

	class ViewsGenerator < Rails::Generators::Base
		include ViewPathTemplates
		source_root File.expand_path('../../../../app/views/chatroom', __FILE__)

		desc "Copies Chatroom views to your application."

		def copy_views
			view_directory :messages
		end
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chatroom-0.1.1 lib/generators/chatroom/views_generator.rb
chatroom-0.1.0 lib/generators/chatroom/views_generator.rb
chatroom-0.0.9 lib/generators/chatroom/views_generator.rb
chatroom-0.0.8 lib/generators/chatroom/views_generator.rb