class Safrano::TypeMapping::Builder1Par

Public Class Methods

new(db_ty_rgx, proc) click to toggle source
# File lib/safrano/type_mapping.rb, line 70
def initialize(db_ty_rgx, proc)
  @db_types_rgx = db_ty_rgx
  @proc = proc
  @rgx = /\A\s*(?:#{@db_types_rgx})\s*\(\s*(\d+)\s*\)\z/i
end

Public Instance Methods

json_value(lambda = nil, &proc) click to toggle source
# File lib/safrano/type_mapping.rb, line 80
def json_value(lambda = nil, &proc)
  @castfunc = block_given? ? proc : lambda
end
match(curtyp) click to toggle source
# File lib/safrano/type_mapping.rb, line 76
def match(curtyp)
  (@md = @rgx.match(curtyp)) ? type_mapping : nil
end
type_mapping() click to toggle source

probably this is not best-practice programing as we have a mutating object (the builder) that produces different lambdas after each type_mapping(mutation) calls

# File lib/safrano/type_mapping.rb, line 93
def type_mapping
  p1val = @md[1]
  instance_exec p1val, &@proc

  TypeMapping1Par.new(self)
end