Class: Schematic::Generator::Names

Inherits:
Object
  • Object
show all
Defined in:
lib/schematic/generator/names.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Names

Returns a new instance of Names.



6
7
8
# File 'lib/schematic/generator/names.rb', line 6

def initialize(klass)
  @klass = klass
end

Instance Attribute Details

#klassObject

Returns the value of attribute klass.



4
5
6
# File 'lib/schematic/generator/names.rb', line 4

def klass
  @klass
end

#rootObject

Returns the value of attribute root.



4
5
6
# File 'lib/schematic/generator/names.rb', line 4

def root
  @root
end

Instance Method Details

#collection_typeObject



22
23
24
# File 'lib/schematic/generator/names.rb', line 22

def collection_type
  type.pluralize
end

#elementObject



14
15
16
# File 'lib/schematic/generator/names.rb', line 14

def element
  element_name
end

#element_collectionObject



18
19
20
# File 'lib/schematic/generator/names.rb', line 18

def element_collection
  element_name.pluralize
end

#nested_attribute_nameObject



26
27
28
# File 'lib/schematic/generator/names.rb', line 26

def nested_attribute_name
  "#{element_collection}-attributes"
end

#typeObject



10
11
12
# File 'lib/schematic/generator/names.rb', line 10

def type
  @klass.name.gsub(/::/,'')
end