Sha256: a5398244102db81527b1d6072331c216b84e4c9dc335c6ff84e6301daf77d99c

Contents?: true

Size: 663 Bytes

Versions: 10

Compression:

Stored size: 663 Bytes

Contents

# allow datetimes to be given as unix times for activeinteractions
module RoquaDateTimeAsUnixFilterExtension
  def cast(value)
    case value
    when Numeric, /^[0-9]+$/
      Time.at(value.to_i).to_datetime
    when ''
      super(nil)
    else
      super
    end
  end
end
ActiveInteraction::DateTimeFilter.include RoquaDateTimeAsUnixFilterExtension

# allow datetimes to be given as unix times as string
module RoquaTimeAsUnixFilterExtension
  def cast(value)
    case value
    when /^[0-9]+$/
      Time.at(value.to_i)
    when ''
      super(nil)
    else
      super
    end
  end
end
ActiveInteraction::TimeFilter.include RoquaTimeAsUnixFilterExtension

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
roqua-support-0.1.21 lib/roqua/core_ext/active_interaction/filters/date_time_as_unix_extension.rb
roqua-support-0.1.20 lib/roqua/core_ext/active_interaction/filters/date_time_as_unix_extension.rb
roqua-support-0.1.19 lib/roqua/core_ext/active_interaction/filters/date_time_as_unix_extension.rb
roqua-support-0.1.18 lib/roqua/core_ext/active_interaction/filters/date_time_as_unix_extension.rb
roqua-support-0.1.17 lib/roqua/core_ext/active_interaction/filters/date_time_as_unix_extension.rb
roqua-support-0.1.16 lib/roqua/core_ext/active_interaction/filters/date_time_as_unix_extension.rb
roqua-support-0.1.15 lib/roqua/core_ext/active_interaction/filters/date_time_as_unix_extension.rb
roqua-support-0.1.14 lib/roqua/core_ext/active_interaction/filters/date_time_as_unix_extension.rb
roqua-support-0.1.13 lib/roqua/core_ext/active_interaction/filters/date_time_as_unix_extension.rb
roqua-support-0.1.12 lib/roqua/core_ext/active_interaction/filters/date_time_as_unix_extension.rb