module B2bCenterApi::WebService::TypeCast::ClassMethods

Public Instance Methods

convert(obj, obj_type) click to toggle source
# File lib/b2b_center_api/web_service/type_cast.rb, line 8
def convert(obj, obj_type)
  return obj if obj.nil?
  case obj_type
  when :string then obj
  when :integer then obj.to_i
  when :float then obj.to_f
  when :date then Date.parse(obj)
  when :time then Time.parse(obj)
  when :boolean then to_boolean(obj)
  else obj
  end
end
to_boolean(obj) click to toggle source
# File lib/b2b_center_api/web_service/type_cast.rb, line 21
def to_boolean(obj)
  return obj if obj.nil?
  obj == '1' ? true : false
end