class StreamitGenerator < Rails::Generators::NamedBase source_root File.expand_path("../templates", __FILE__) class_option :migration, :type => :boolean, :default => true def invoke_model invoke "model", [name].concat(migration_columns), :timestamps => false, :test_framework => false, :migration => options.migration? end def add_model_config inject_into_class "app/models/#{file_name}.rb", class_name, <<-CONTENT include Streamit::ORM::#{Rails::Generators.options[:rails][:orm].to_s.camelize} CONTENT end def add_application_config inject_into_class "config/application.rb", "Application", <<-CONTENT # Set stream store config.streamit.set_store = lambda { ::#{class_name} } CONTENT end def create_stream_view copy_file "_stream.html.erb", "app/views/streamit/streams/_stream.html.erb" end protected def migration_columns %w(stream_type:string started_at:datetime actor_id:integer actor_type:string subject_id:integer subject_type:string receiver_id:integer receiver_type:string) end end