Module: Sofav::Decorator

Included in:
Generators::SofavGenerator
Defined in:
lib/sofav/decorator.rb

Instance Method Summary collapse

Instance Method Details

#create_decorator(file_name, class_name, attributes) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/sofav/decorator.rb', line 3

def create_decorator(file_name, class_name, attributes)
  @attr = ''

  attributes.each do |a|
    @attr += "#{a.name} "
  end

  create_file "app/decorator/#{file_name}_decorator.rb", "class \#{class_name}Decorator < BaseDecorator\n  include EnumerizeConcern\n\n  collection_search do\n   {name: \"q\", search_in: [], placeholder: '', action: '/admin/\#{class_name}', fuzzy: true}\n  end\n\n  collection_attributes do\n[\"#\", ]\n  end\n\n  permitted_class_methods do\n{index: [\"new\"]}\n  end\n\n  permitted_instance_methods do\n{index: [\"show\", \"edit\", \"destroy\"], show: [\"edit\"]}\n  end\n\n  form_attributes do\n{\n  profiles: %w{base_info},\n  base_info: %w{\#{@attr}}\n}\n  end\n\n  show_page_attributes do\n{\n  profiles: %w{base_info},\n  base_info: %w{\#{@attr}}\n}\n  end\nend\n  FILE\nend\n"