Class: Migr8::Util::TemplateContext

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

Instance Method Summary collapse

Constructor Details

#initialize(vars = {}) ⇒ TemplateContext



2299
2300
2301
2302
2303
2304
2305
# File 'lib/migr8.rb', line 2299

def initialize(vars={})
  #; [!p69q1] takes vars and sets them into instance variables.
  #; [!p853f] do nothing when vars is nil.
  vars.each do |k, v|
    instance_variable_set("@#{k}", v)
  end if vars
end

Instance Method Details

#escape(value) ⇒ Object



2307
2308
2309
2310
2311
2312
2313
# File 'lib/migr8.rb', line 2307

def escape(value)
  #; [!6v5yq] escapes "'" into "\\'" when on MySQL dbms.
  return $MIGR8_DBMS.q(value.to_s) if $MIGR8_DBMS
  #; [!f3yy9] escapes "'" into "''" for default.
  #; [!to5kz] converts any value into string.
  return value.to_s.gsub(/'/, "''")
end