Class: Fae::BaseGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Fae::BaseGenerator
show all
- Defined in:
- lib/generators/fae/base_generator.rb
Constant Summary
collapse
- @@attributes_flat =
[]
- @@attribute_names =
[]
- @@association_names =
[]
- @@attachments =
[]
- @@has_position =
false
- @@display_field =
''
Instance Method Summary
collapse
Instance Method Details
#check_template_support ⇒ Object
15
16
17
18
|
# File 'lib/generators/fae/base_generator.rb', line 15
def check_template_support
supported_templates = ['slim']
raise "Fae::UnsupportedTemplate: the template engine you defined isn't supported" unless supported_templates.include?(options.template)
end
|
#set_globals ⇒ Object
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
|
# File 'lib/generators/fae/base_generator.rb', line 20
def set_globals
if attributes.present?
attributes.each do |arg|
if is_attachment(arg)
@@attachments << arg
else
@@attributes_flat << "#{arg.name}:#{arg.type}"
end
if arg.name['_id'] || arg.type.to_s == 'references'
@@association_names << arg.name.gsub('_id', '')
elsif !is_attachment(arg)
@@attribute_names << arg.name
end
@@has_position = true if arg.name === 'position'
end
@@attributes_flat = @@attributes_flat.uniq.join(' ')
@@association_names.uniq!
@@attribute_names.uniq!
@@attachments.uniq!
end
end
|