Class: BaseScaffold

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

Instance Method Summary collapse

Constructor Details

#initialize(model, attributes = {}) ⇒ BaseScaffold

Returns a new instance of BaseScaffold



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

#base_pathObject



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

def base_path
  model_parameter_name.pluralize
end

#class_nameObject



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

def class_name
  @model.camelize
end

#controller_class_nameObject



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

def controller_class_name
  "#{class_name}Controller"
end

#controller_test_class_nameObject



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

def controller_test_class_name
  "#{controller_class_name}Test"
end

#controller_test_paramObject



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

#importsObject



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

#model_parameter_nameObject



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

def model_parameter_name
  @model.camelize(:lower)
end

#repository_impl_nameObject



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

def repository_impl_name
  "#{repository_interface_name}Impl"
end

#repository_interface_nameObject



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

def repository_interface_name
  "#{class_name}Repository"
end

#repository_test_class_nameObject



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

def repository_test_class_name
  "#{repository_impl_name}Test"
end

#test_class_nameObject



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

def test_class_name
  "#{class_name}Test"
end