Skip to content

Commit

Permalink
protect methods, so they are not called as generators
Browse files Browse the repository at this point in the history
  • Loading branch information
maccman committed Oct 23, 2011
1 parent 4b1a74f commit fa8e95c
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions lib/generators/spine/scaffold/scaffold_generator.rb
Expand Up @@ -9,24 +9,8 @@ class ScaffoldGenerator < Base

argument :fields, :desc => "List of model attributes", :type => :array, :banner => "field1 field2"

def model_name
file_name.singularize
end

def model_class
class_name.singularize
end

def controller_name
file_name.pluralize
end

def controller_class
class_name.pluralize
end

def create_scaffold
raise("Eco required - please add to Gemfile") unless defined?(::Eco)
raise("The 'eco' gem is required; add it to the Gemfile") unless defined?(::Eco)

generate "spine:model #{model_name} #{fields.join(" ")} --app #{app_name}"
template "controller.coffee.erb", "app/assets/javascripts/#{app_name}/controllers/#{controller_name}.js.coffee"
Expand All @@ -35,6 +19,24 @@ def create_scaffold
template "new.jst.erb", "app/assets/javascripts/#{app_name}/views/#{controller_name}/new.jst.eco"
template "show.jst.erb", "app/assets/javascripts/#{app_name}/views/#{controller_name}/show.jst.eco"
end

protected

def model_name
file_name.singularize
end

def model_class
class_name.singularize
end

def controller_name
file_name.pluralize
end

def controller_class
class_name.pluralize
end
end
end
end

0 comments on commit fa8e95c

Please sign in to comment.