Class: ActiveModel::Generators::ModelGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/generators/active_model/model/model_generator.rb

Instance Method Summary collapse

Methods inherited from Base

source_root

Instance Method Details

#accessor_propertiesObject



34
35
36
# File 'lib/generators/active_model/model/model_generator.rb', line 34

def accessor_properties
  attributes.select{|attr| attr.type == :all }.map{|attr| ":#{attr.name}" }.join(",")
end

#accessor_properties?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/generators/active_model/model/model_generator.rb', line 30

def accessor_properties?
  attributes.any?{|attr| attr.type == :all }
end

#create_model_fileObject



10
11
12
# File 'lib/generators/active_model/model/model_generator.rb', line 10

def create_model_file
  template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
end

#read_propertiesObject



18
19
20
# File 'lib/generators/active_model/model/model_generator.rb', line 18

def read_properties
  attributes.select{|attr| attr.type == :read}.map{|attr| ":#{attr.name}" }.join(",")
end

#read_properties?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/generators/active_model/model/model_generator.rb', line 14

def read_properties?
  attributes.any?{|attr| attr.type == :read }
end

#write_propertiesObject



26
27
28
# File 'lib/generators/active_model/model/model_generator.rb', line 26

def write_properties
  attributes.select{|attr| attr.type == :write }.map{|attr| ":#{attr.name}" }.join(",")
end

#write_properties?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/generators/active_model/model/model_generator.rb', line 22

def write_properties?
  attributes.any?{|attr| attr.type == :write }
end