Class: DMGen::OneFile

Inherits:
Templater::Generator
  • Object
show all
Defined in:
lib/dm-gen/generators/one_file.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



19
20
21
# File 'lib/dm-gen/generators/one_file.rb', line 19

def self.source_root
  File.join(File.dirname(__FILE__), '..', 'templates')
end

Instance Method Details

#filenameObject



32
33
34
# File 'lib/dm-gen/generators/one_file.rb', line 32

def filename
  name.sub(/\.rb\z/,'')
end

#model_nameObject



28
29
30
# File 'lib/dm-gen/generators/one_file.rb', line 28

def model_name
  (model) ? model.camel_case : "TestModel"
end

#propertiesObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dm-gen/generators/one_file.rb', line 36

def properties
  h = {}
  attributes.each do |k, v|
    # skip if the property is named id
    next if k == "id"

    # convert to snake/camel case
    h[k.snake_case] = v.camel_case
  end
  h
end