class SafeDb::Rename
The rename use case when applied at the verse level changes the stated line keyname.
Attributes
new_name[W]
The id of the current chapter, verse or line entity to be renamed is the now_name
and its new name is the new_name.
now_name[W]
The id of the current chapter, verse or line entity to be renamed is the now_name
and its new name is the new_name.
Public Instance Methods
edit_verse()
click to toggle source
Find the line key named now_name
and replace it with the provided new_name. The validation for keynames applies, both must be provided and the now_name
must exist. This use case also renames file keys.
# File lib/controller/edit/rename.rb, line 17 def edit_verse() # @todo refactor to recognise file values using isMap rather than the string prefix # @todo refactor the Remove, Show, Read and Write use cases as well as this one. exit(100) unless has_line?() current_value = @verse[ @now_name ] # @todo instead of store and delete use the hash key rename method @verse.store( @new_name, current_value ) unless is_file?() @verse.store( "#{Indices::INGESTED_FILE_LINE_NAME_KEY}#{@new_name}", current_value ) if is_file?() @verse.delete( "#{Indices::INGESTED_FILE_LINE_NAME_KEY}#{@now_name}" ) @verse.delete( @now_name ) end
Private Instance Methods
has_line?()
click to toggle source
# File lib/controller/edit/rename.rb, line 43 def has_line?() return true if( @verse.has_key?( @now_name ) || @verse.has_key?( "#{Indices::INGESTED_FILE_LINE_NAME_KEY}#{@now_name}" ) ) @book.print_book_mark() puts "" puts "Line [ #{@now_name} ] is not in this chapter/verse." puts "" return false end
is_file?()
click to toggle source
# File lib/controller/edit/rename.rb, line 39 def is_file?() return @verse.has_key?( "#{Indices::INGESTED_FILE_LINE_NAME_KEY}#{@now_name}" ) end