Class: Sofav::Generators::SofavGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Decorator, Local
Defined in:
lib/generators/sofav/sofav_generator.rb

Instance Method Summary collapse

Methods included from Decorator

#create_decorator

Methods included from Local

#create_config_attribute, #create_config_record

Instance Method Details

#create_controllerObject



24
25
26
# File 'lib/generators/sofav/sofav_generator.rb', line 24

def create_controller
  generate "controller", "Admin::#{file_name} --skip-routes"
end

#create_kaminariObject



28
29
30
# File 'lib/generators/sofav/sofav_generator.rb', line 28

def create_kaminari
    generate "kaminari:views", "default --views-prefix admin"
end

#create_locales_activerecordObject



32
33
34
35
36
37
38
39
# File 'lib/generators/sofav/sofav_generator.rb', line 32

def create_locales_activerecord
  @record = Array.new
  attributes.each do |a|
    @record << a.name
  end

  create_config_record(file_name, @record)
end

#create_locales_attribute_typesObject



41
42
43
# File 'lib/generators/sofav/sofav_generator.rb', line 41

def create_locales_attribute_types
  create_config_attribute(file_name, attributes)
end

#create_modelObject



14
15
16
17
18
19
20
21
22
# File 'lib/generators/sofav/sofav_generator.rb', line 14

def create_model
  @agruments = "#{file_name}"

  attributes.each do |a|
    @agruments += " #{a.name}:#{a.type}"
  end

  generate "model", @agruments
end

#create_model_decoratorObject



45
46
47
# File 'lib/generators/sofav/sofav_generator.rb', line 45

def create_model_decorator
  create_decorator(file_name, class_name, attributes)
end