Module: B2bCenterApi::WebService::TypeCast::ClassMethods
- Defined in:
- lib/b2b_center_api/web_service/type_cast.rb
Instance Method Summary collapse
Instance Method Details
#convert(obj, obj_type) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# 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) ⇒ Object
21 22 23 24 |
# 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 |