Class: Ink::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/webinkforms.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_refstr(refstr) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/webinkforms.rb', line 63

def self.from_refstr(refstr)
  if refstr =~ /^([^:]+):(.+)$/ and klass = self.classname($1)
    Ink::Database.database.find(klass, "WHERE #{klass.primary_key}=#{$2}").
      first
  else
    nil
  end
end

Instance Method Details

#to_refstr(prefix = "") ⇒ Object



59
60
61
# File 'lib/webinkforms.rb', line 59

def to_refstr(prefix="")
  pk ? "#{prefix}#{self.class.class_name}:#{pk}" : nil
end