Sha256: 8b86ad6b02d4d1f4d25bf5c5bdb42d5d6d5a03ab8da0bc6aba60c41fd8452f92

Contents?: true

Size: 943 Bytes

Versions: 3

Compression:

Stored size: 943 Bytes

Contents

module Torque
  module PostgreSQL
    # = Torque PostgreSQL Railtie
    class Railtie < Rails::Railtie # :nodoc:

      # Get information from the running rails app
      initializer 'torque-postgresql' do |app|
        Torque::PostgreSQL.config.eager_load = app.config.eager_load

        # Include enum on ActiveRecord::Base so it can have the correct enum
        # initializer
        Torque::PostgreSQL::Attributes::Enum.include_on(ActiveRecord::Base)

        # Define a method to find yet to define constants
        Torque::PostgreSQL.config.enum.namespace.define_singleton_method(:const_missing) do |name|
          Torque::PostgreSQL::Attributes::Enum.lookup(name)
        end

        # Define a helper method to get a sample value
        Torque::PostgreSQL.config.enum.namespace.define_singleton_method(:sample) do |name|
          Torque::PostgreSQL::Attributes::Enum.lookup(name).sample
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
torque-postgresql-0.2.16 lib/torque/postgresql/railtie.rb
torque-postgresql-0.2.15 lib/torque/postgresql/railtie.rb
torque-postgresql-0.2.14 lib/torque/postgresql/railtie.rb