Sha256: 0c6a395a4257bbb50f32721fa8293d3a4c8ff1a8235bd398d2bc57abd236c6f5

Contents?: true

Size: 1.82 KB

Versions: 16

Compression:

Stored size: 1.82 KB

Contents

require 'vigilante/controller_extension'
require 'vigilante/active_record_extensions'

module Vigilante

  #define exceptions
  module ExceptionsMixin
    def initialize(str)
      super("Vigilante: " + str)
    end
  end
  class ArgumentError < ::ArgumentError #:nodoc:
    include ExceptionsMixin
  end

  class AccessDenied < ::StandardError #:nodoc:
    include ExceptionsMixin
    def initialize(str='Access denied: you do not have the right permissions for the requested action.')
      super(str)
    end
  end  


  class Engine < ::Rails::Engine

    # configure our plugin on boot
    initializer "vigilante.initialize" do |app|
      # mixin our code
      ActionController::Base.send(:include, Vigilante::ControllerExtension)
      ActiveRecord::Base.send(:include, Vigilante::ActiveRecordExtensions)

      #load configuration files if they are available
      vigilante_config_file         = File.join("#{Rails.root.to_s}", 'config', 'vigilante_config.yml')
      default_vigilante_config_file = File.join(File.dirname(__FILE__), 'config', 'vigilante_config.yml')
      default_vigilante_config_file = vigilante_config_file if File.exist?(vigilante_config_file)

      if File.exist?(default_vigilante_config_file)
        Rails.logger.debug "define VIGILANTE_CONFIG"
        raw_config = File.read(default_vigilante_config_file)
        ::VIGILANTE_CONFIG = YAML.load(raw_config)["#{Rails.env}"]
      else
        raise Vigilante::ArgumentError.new("The vigilante_config.yml is missing. Path=#{default_vigilante_config_file} Did you run the generator vigilante:install? ")
      end
    end

    initializer :append_migrations do |app|
      unless app.root.to_s.match root.to_s
        config.paths["db/migrate"].expanded.each do |expanded_path|
          app.config.paths["db/migrate"] << expanded_path
        end
      end
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
vigilante-1.0.19 lib/vigilante.rb
vigilante-1.0.18 lib/vigilante.rb
vigilante-1.0.17 lib/vigilante.rb
vigilante-1.0.16 lib/vigilante.rb
vigilante-1.0.15 lib/vigilante.rb
vigilante-1.0.14 lib/vigilante.rb
vigilante-1.0.13 lib/vigilante.rb
vigilante-1.0.12 lib/vigilante.rb
vigilante-1.0.11 lib/vigilante.rb
vigilante-1.0.10 lib/vigilante.rb
vigilante-1.0.9 lib/vigilante.rb
vigilante-1.0.8 lib/vigilante.rb
vigilante-1.0.7 lib/vigilante.rb
vigilante-1.0.6 lib/vigilante.rb
vigilante-1.0.5 lib/vigilante.rb
vigilante-1.0.4 lib/vigilante.rb