Module: Rails3::Assist::Artifact::CRUD::Update
- Defined in:
- lib/rails3_artifactor/base/crud/update.rb
Instance Method Summary collapse
- #insert_into_artifact(name, options = {}, &block) ⇒ Object (also: #update_artifact)
- #remove_from_artifact(name, options = {}, &block) ⇒ Object
- #remove_from_artifacts(*names, &block) ⇒ Object
- #replace_in_artifact(name, options = {}, &block) ⇒ Object
- #replace_in_artifacts(*names, &block) ⇒ Object
Instance Method Details
#insert_into_artifact(name, options = {}, &block) ⇒ Object Also known as: update_artifact
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rails3_artifactor/base/crud/update.rb', line 5 def insert_into_artifact name, ={}, &block type = get_type() file = existing_file_name(name, type) raise "No file could be determined: #{file} from name: #{name} of type: #{type}" if !file raise "File to insert in not found: #{file} for #{type}" if !File.file?(file) marker = marker_option(name, ) blip = send :"#{type}_marker", name, = .merge marker res = File.insert_into file, , &block if !res # try with :embedded option if default doesn't work mrk_opt = marker_option name, .merge(:model_type => :embedded) .merge! mrk_opt File.insert_into file, , &block end end |
#remove_from_artifact(name, options = {}, &block) ⇒ Object
28 29 30 31 32 |
# File 'lib/rails3_artifactor/base/crud/update.rb', line 28 def remove_from_artifact name, ={}, &block type = [:type] file = existing_file_name(name, type) File.remove_content_from file, , &block end |
#remove_from_artifacts(*names, &block) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rails3_artifactor/base/crud/update.rb', line 34 def remove_from_artifacts *names, &block = last_option(names) type = [:type] artifacts = names.flatten.select_labels artifacts.each do |name| file = existing_file_name(name, type) File.remove_content_from file, , &block end end |
#replace_in_artifact(name, options = {}, &block) ⇒ Object
46 47 48 49 50 |
# File 'lib/rails3_artifactor/base/crud/update.rb', line 46 def replace_in_artifact name, ={}, &block type = [:type] file = existing_file_name(name, type) File.replace_content_from file, , &block end |
#replace_in_artifacts(*names, &block) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rails3_artifactor/base/crud/update.rb', line 52 def replace_in_artifacts *names, &block = last_option(names) type = [:type] artifacts = names.flatten.select_labels artifacts.each do |name| file = existing_file_name(name, type) File.replace_content_from file, , &block end end |