Class: Merb::Generators::ResourceControllerGenerator

Inherits:
ComponentGenerator show all
Defined in:
lib/merb-gen/resource_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Generator

#initialize, #with_modules

Constructor Details

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

Class Method Details

.source_rootObject



5
6
7
# File 'lib/merb-gen/resource_controller.rb', line 5

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

Instance Method Details

#controller_class_nameObject



47
48
49
# File 'lib/merb-gen/resource_controller.rb', line 47

def controller_class_name
  chunks.last
end

#controller_modulesObject



43
44
45
# File 'lib/merb-gen/resource_controller.rb', line 43

def controller_modules
  chunks[0..-2]
end

#file_nameObject



55
56
57
# File 'lib/merb-gen/resource_controller.rb', line 55

def file_name
  controller_class_name.snake_case
end

#model_class_nameObject



59
60
61
# File 'lib/merb-gen/resource_controller.rb', line 59

def model_class_name
  controller_class_name.singularize
end

#params_for_getObject

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



72
73
74
# File 'lib/merb-gen/resource_controller.rb', line 72

def params_for_get
  "params[:id]"
end

#plural_modelObject



63
64
65
# File 'lib/merb-gen/resource_controller.rb', line 63

def plural_model
  controller_class_name.snake_case
end

#propertiesObject

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



77
78
79
# File 'lib/merb-gen/resource_controller.rb', line 77

def properties
  []
end

#singular_modelObject



67
68
69
# File 'lib/merb-gen/resource_controller.rb', line 67

def singular_model
  plural_model.singularize
end

#test_class_nameObject



51
52
53
# File 'lib/merb-gen/resource_controller.rb', line 51

def test_class_name
  controller_class_name + "Test"
end