Module: Arcade::Support::String2

Defined in:
lib/support/conversions.rb

Instance Method Summary collapse

Instance Method Details

#from_dbObject Also known as: expand

from db translates the database response into active-orient objects

symbols are representated via “:something]:”

database records respond to the “rid”-method

other values are not modified



246
247
248
249
250
251
252
253
254
255
# File 'lib/support/conversions.rb', line 246

def from_db
  if rid?
    Arcade::Init.db.get  self
  elsif  self =~ /^:.*:$/
    # symbol-representation in the database
    self[1..-2].to_sym
  else
    self
  end
end

#to_dbObject

if the string contains “#xx:yy” omit quotes



259
260
261
# File 'lib/support/conversions.rb', line 259

def to_db
  rid? ? "#"+rid : self   # return the string (not the quoted string. this is to_or)
end

#to_orObject



263
264
265
# File 'lib/support/conversions.rb', line 263

def to_or
  quote
end