Module: Angus::Unmarshalling
- Defined in:
- lib/angus/unmarshalling.rb
Class Method Summary collapse
Class Method Details
.unmarshal_scalar(scalar, type) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/angus/unmarshalling.rb', line 8 def self.unmarshal_scalar(scalar, type) return nil if scalar.nil? case type when :string #scalar.force_encoding(Encoding::UTF_8) scalar when :integer scalar when :boolean scalar when :date Date.iso8601(scalar) when :date_time DateTime.iso8601(scalar) when :decimal BigDecimal.new(scalar) when :object scalar else raise ArgumentError, "Unkonwn type: #{type}" end end |