Module: RailsAssist::Artifact::CRUD::Create

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

Instance Method Summary collapse

Methods included from Marker

#marker

Instance Method Details

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



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rails_artifactor/base/crud/create.rb', line 7

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(RailsAssist::RubyMutator)
    content.remove_superclass
    content.inherit_from "#{superclass}_permit"
  end

  return if content.blank?

  File.overwrite file, content
end