Module: Timeline::Helpers
- Included in:
- Timeline
- Defined in:
- lib/timeline/helpers.rb
Defined Under Namespace
Classes: DecodeException
Instance Method Summary collapse
Instance Method Details
#decode(object) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/timeline/helpers.rb', line 15 def decode(object) return unless object begin if ::MultiJson::VERSION.to_f > 1.3 ::MultiJson.load(object) else ::MultiJson.decode(object) end rescue ::MultiJson::DecodeError => e raise DecodeException, e end end |
#encode(object) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/timeline/helpers.rb', line 7 def encode(object) if ::MultiJson::VERSION.to_f > 1.3 ::MultiJson.dump(object) else ::MultiJson.encode(object) end end |