Sha256: 207299508cc1016a066b2d583ba85503e0dc368a2368224332b9b05e6bb6084a

Contents?: true

Size: 457 Bytes

Versions: 9

Compression:

Stored size: 457 Bytes

Contents

module AuditRails
  module DBExtension
    def adapter_type
      connection.adapter_name.downcase.to_sym
    end

    def hourly(column)
      case adapter_type
      when :mysql, :mysql2
        "hour(#{column})"
      when :sqlite, :sqlite3
        "strftime('%H', #{column})"
      when :postgresql
        "DATE_PART('hour', #{column})"
      else
        raise NotImplementedError, "Unknown adapter type '#{adapter_type}'"
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
audit_rails-2.0.10 lib/audit_rails/db_extension.rb
audit_rails-2.0.9 lib/audit_rails/db_extension.rb
audit_rails-2.0.8 lib/audit_rails/db_extension.rb
audit_rails-2.0.7 lib/audit_rails/db_extension.rb
audit_rails-2.0.6 lib/audit_rails/db_extension.rb
audit_rails-2.0.5 lib/audit_rails/db_extension.rb
audit_rails-2.0.4 lib/audit_rails/db_extension.rb
audit_rails-2.0.3 lib/audit_rails/db_extension.rb
audit_rails-2.0.2 lib/audit_rails/db_extension.rb