Class: DateTime
- Defined in:
- lib/ripple/core_ext/casting.rb,
lib/ripple/core_ext/indexes.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.ripple_cast(value) ⇒ Object
125 126 127 128 |
# File 'lib/ripple/core_ext/casting.rb', line 125 def self.ripple_cast(value) return nil if value.blank? value.respond_to?(:to_datetime) && value.to_datetime or raise Ripple::PropertyTypeMismatch.new(self, value) end |
Instance Method Details
#as_json(options = {}) ⇒ Object
121 122 123 |
# File 'lib/ripple/core_ext/casting.rb', line 121 def as_json(={}) self.utc.to_s(Ripple.date_format) end |
#to_ripple_index(type) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/ripple/core_ext/indexes.rb', line 51 def to_ripple_index(type) case type when 'bin' utc.to_s(Ripple.date_format) when 'int' (utc.to_f * 1000).round end end |