Module: Rails3Generators::Helpers::Model

Defined in:
lib/generators/helpers/model_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#model_attributesObject

Returns the value of attribute model_attributes.



5
6
7
# File 'lib/generators/helpers/model_helper.rb', line 5

def model_attributes
  @model_attributes
end

#model_indexesObject

Returns the value of attribute model_indexes.



5
6
7
# File 'lib/generators/helpers/model_helper.rb', line 5

def model_indexes
  @model_indexes
end

Instance Method Details

#arg_name(arg) ⇒ Object



12
13
14
# File 'lib/generators/helpers/model_helper.rb', line 12

def arg_name(arg)
  arg.split(':').first        
end

#arg_type(arg) ⇒ Object



16
17
18
# File 'lib/generators/helpers/model_helper.rb', line 16

def arg_type(arg)
  arg.split(':')[1] || 'string'
end

#class_nameObject



36
37
38
# File 'lib/generators/helpers/model_helper.rb', line 36

def class_name
  model_name.camelize
end

#model_exists?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/generators/helpers/model_helper.rb', line 24

def model_exists?
  File.exist? destination_path("app/models/#{singular_name}.rb")
end

#model_nameObject



20
21
22
# File 'lib/generators/helpers/model_helper.rb', line 20

def model_name
  name
end

#parse_model_attributes(with_indexes = true) ⇒ Object



7
8
9
10
# File 'lib/generators/helpers/model_helper.rb', line 7

def parse_model_attributes(with_indexes = true)
  @model_attributes = []
  @model_indexes = {}
end

#plural_class_nameObject



40
41
42
# File 'lib/generators/helpers/model_helper.rb', line 40

def plural_class_name
  plural_name.camelize
end

#plural_nameObject



32
33
34
# File 'lib/generators/helpers/model_helper.rb', line 32

def plural_name
  model_name.underscore.pluralize
end

#singular_nameObject



28
29
30
# File 'lib/generators/helpers/model_helper.rb', line 28

def singular_name
  model_name.underscore
end