class Safrano::TypeMapping::Builder

wrapper to handle API

Attributes

bui1[R]
bui2[R]
castfunc[R]
db_types_rgx[R]
xedm_type[R]

Public Class Methods

new(*dbtyps) click to toggle source
# File lib/safrano/type_mapping.rb, line 24
def initialize(*dbtyps)
  @db_types_rgx = dbtyps.join('|')
  @rgx = /\A\s*(?:#{@db_types_rgx})\s*\z/i
end

Public Instance Methods

edm_type(input) click to toggle source
# File lib/safrano/type_mapping.rb, line 29
def edm_type(input)
  @xedm_type = input
end
json_value(lambda = nil, &proc) click to toggle source
# File lib/safrano/type_mapping.rb, line 43
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 47
def match(curtyp)
  if (@bui2 && (m = @bui2.match(curtyp)))
    m
  elsif (@bui1 && (m = @bui1.match(curtyp)))
    m
  elsif  @rgx.match(curtyp)
    type_mapping
  end
end
type_mapping() click to toggle source
# File lib/safrano/type_mapping.rb, line 57
def type_mapping
  # TODO perf; return always same object when called multiple times
  FixedTypeMapping.new(self)
end
with_one_param(lambda = nil, &proc) click to toggle source
# File lib/safrano/type_mapping.rb, line 33
def with_one_param(lambda = nil, &proc)
  proc1 = block_given? ? proc : lambda
  @bui1 = Builder1Par.new(@db_types_rgx, proc1)
end
with_two_params(lambda = nil, &proc) click to toggle source
# File lib/safrano/type_mapping.rb, line 38
def with_two_params(lambda = nil, &proc)
  proc2 = block_given? ? proc : lambda
  @bui2 = Builder2Par.new(@db_types_rgx, proc2)
end