Class: Cullender::Generators::CullenderGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
OrmHelpers, Rails::Generators::Migration
Defined in:
lib/generators/cullender/cullender_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OrmHelpers

#migration_exists?, #migration_path, #model_contents, #model_exists?, #model_path

Class Method Details

.next_migration_number(path) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/generators/cullender/cullender_generator.rb', line 17

def self.next_migration_number(path)
	unless @prev_migration_nr
		@prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
	else
		@prev_migration_nr += 1
	end
	@prev_migration_nr.to_s
end

Instance Method Details

#add_cullender_routesObject



27
28
29
30
31
32
# File 'lib/generators/cullender/cullender_generator.rb', line 27

def add_cullender_routes
	cullender_route  = "cullender_for :#{plural_name}"
	cullender_route << %Q(, :class_name => "#{class_name}") if class_name.include?("::")
	cullender_route << %Q(, :skip => :all) unless options.routes?
	route cullender_route
end

#copy_cullender_rules_migrationObject



35
36
37
# File 'lib/generators/cullender/cullender_generator.rb', line 35

def copy_cullender_rules_migration
	migration_template "cullender_migration.rb", "db/migrate/create_cullender_tables"
end

#migration_dataObject



66
67
68
69
70
71
72
# File 'lib/generators/cullender/cullender_generator.rb', line 66

def migration_data
<<RUBY
		t.string :name
		t.boolean :enabled
		t.text :triggers				
RUBY
end