Class: BaseScaffold

Inherits:
VraptorScaffold::Base show all
Defined in:
lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb

Direct Known Subclasses

ControllerGenerator, ModelGenerator, ObjectifyModelGenerator, ObjectifyRepositoryGenerator, RepositoryGenerator, TemplateEngineGenerator

Instance Method Summary (collapse)

Constructor Details

- (BaseScaffold) initialize(model, attributes = {})



3
4
5
6
7
# File 'lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb', line 3

def initialize(model, attributes={})
  super
  @model = model
  @attributes = attributes
end

Instance Method Details

- (Object) base_path



49
50
51
# File 'lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb', line 49

def base_path
  model_parameter_name.pluralize
end

- (Object) class_name



13
14
15
# File 'lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb', line 13

def class_name
  @model.camelize
end

- (Object) controller_class_name



33
34
35
# File 'lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb', line 33

def controller_class_name
  "#{class_name}Controller"
end

- (Object) controller_test_class_name



37
38
39
# File 'lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb', line 37

def controller_test_class_name
  "#{controller_class_name}Test"
end

- (Object) controller_test_param



41
42
43
44
45
46
47
# File 'lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb', line 41

def controller_test_param
  params = ""
  @attributes.each do |att|
    params += ", null"  if att.type.eql?("references")
  end
  params    
end

- (Object) imports



53
54
55
56
57
58
59
60
61
# File 'lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb', line 53

def imports
  imports = []
  @attributes.each do |attribute|
    attribute.import.each do |import|
      imports << import unless imports.include?(import)      
    end
  end
  imports
end

- (Object) model_parameter_name



9
10
11
# File 'lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb', line 9

def model_parameter_name
  @model.camelize(:lower)
end

- (Object) repository_impl_name



25
26
27
# File 'lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb', line 25

def repository_impl_name
  "#{repository_interface_name}Impl"
end

- (Object) repository_interface_name



21
22
23
# File 'lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb', line 21

def repository_interface_name
  "#{class_name}Repository"
end

- (Object) repository_test_class_name



29
30
31
# File 'lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb', line 29

def repository_test_class_name
  "#{repository_impl_name}Test"
end

- (Object) test_class_name



17
18
19
# File 'lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb', line 17

def test_class_name
  "#{class_name}Test"
end