Module: Rails3::Assist::Artifact::CRUD::Create

Includes:
Marker
Defined in:
lib/rails3_artifactor/base/crud/create.rb

Instance Method Summary collapse

Methods included from Marker

#marker

Instance Method Details

#create_artifact(name, options = {}, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rails3_artifactor/base/crud/create.rb', line 15

def create_artifact name, options={}, &block
  type = get_type(options)
  file = make_file_name(name, type)
  return nil if File.exist?(file) && options[:no_overwrite]

  create_artifact_dir(file)      
  content = get_content(name, type, options, &block)
  
  superclass = options[:superclass] if options[:superclass]

  if superclass
    content.extend(RubyMutator)
    content.remove_superclass
    content.inherit_from "#{superclass}_permit"
  end
  
  return if content.blank?

  File.overwrite file, content      
end