Class: FmModelGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



25
26
27
# File 'lib/generators/fm_model/fm_model_generator.rb', line 25

def self.source_root
  File.join(File.dirname(__FILE__), 'templates')
end

Instance Method Details

#create_model_fileObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/generators/fm_model/fm_model_generator.rb', line 7

def create_model_file
  config = FmStore::Config.instance
  
  server = Rfm::Server.new({
      :host         => config.host,
      :account_name => config.,
      :password     => config.password,
      :ssl          => config.ssl,
      :log_actions  => config.log_actions
  })
  
  conn = server[database_name][layout_name]
  
  @fields = conn.any.first.keys
  
  template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
end