Class: Fae::BaseGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/fae/base_generator.rb

Constant Summary collapse

@@attributes_flat =
[]
@@attribute_names =
[]
@@association_names =
[]
@@has_position =
false
@@display_field =
''

Instance Method Summary collapse

Instance Method Details

#check_template_supportObject



14
15
16
17
# File 'lib/generators/fae/base_generator.rb', line 14

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_globalsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/fae/base_generator.rb', line 19

def set_globals
  if attributes.present?
    attributes.each do |arg|
      @@attributes_flat << "#{arg.name}:#{arg.type}"
      if arg.name['_id'] || arg.type.to_s == 'references'
        @@association_names << arg.name.gsub('_id', '')
      else
        @@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!
  end
end