Class: Merb::Generators::ResourceControllerGenerator

Inherits:
NamespacedGenerator show all
Defined in:
lib/generators/resource_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NamespacedGenerator

#base_path, #class_name, #file_name, #full_class_name, #modules

Methods inherited from NamedGenerator

#class_name, #file_name, #symbol_name, #test_class_name

Methods inherited from Generator

#go_up, #initialize, #with_modules

Constructor Details

This class inherits a constructor from Merb::Generators::Generator

Class Method Details

.source_rootObject



5
6
7
# File 'lib/generators/resource_controller.rb', line 5

def self.source_root
  File.join(super, 'component', 'resource_controller')
end

Instance Method Details

#model_class_nameObject



52
53
54
# File 'lib/generators/resource_controller.rb', line 52

def model_class_name
  class_name.singularize
end

#params_for_getObject

TODO: fix this for Datamapper, so that it returns the primary keys for the model



69
70
71
# File 'lib/generators/resource_controller.rb', line 69

def params_for_get
  "params[:id]"
end

#plural_modelObject



56
57
58
# File 'lib/generators/resource_controller.rb', line 56

def plural_model
  class_name.snake_case
end

#propertiesObject

TODO: implement this for Datamapper so that we get the model properties



74
75
76
# File 'lib/generators/resource_controller.rb', line 74

def properties
  []
end

#resource_pathObject



64
65
66
# File 'lib/generators/resource_controller.rb', line 64

def resource_path
  chunks.map{ |c| c.snake_case }.join('/')
end

#singular_modelObject



60
61
62
# File 'lib/generators/resource_controller.rb', line 60

def singular_model
  plural_model.singularize
end