Sha256: 9fa64fff438629d4340957ae5bda8c8746ea831ab80f160a07d0c7b28fba044b

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

module AutoError
  module Config
    def self.setup( &blk )
      yield self
    end

    mattr_accessor :auth_with
    @@auth_with = nil

    mattr_accessor :helpers
    @@helpers = nil

    mattr_accessor :email_on_error
    @@email_on_error = nil

    mattr_accessor :email_sender
    @@email_sender =

    mattr_accessor :error_template_renderer
    @@error_template_renderer = nil

    mattr_accessor :data_handlers
    @@data_handlers = nil

    private

    def self.set_defaults
      self.setup do |config|
        config.error_template_renderer = ->( status ) do
          render template: "/errors/#{status}",
                 layout: 'errors',
                 status: status
        end

        config.email_sender = %{"Notifier" notifications@example.com}
        config.email_on_error = []
        ExceptionNotifier::Notifier.prepend_view_path(
          AutoError::Engine.root.join( *%w{app views auto_error} )
        )

        config.auth_with = ->( c ) { true }
        config.helpers = [ 'ApplicationHelper' ]

        config.data_handlers = Hash.new do |h, k|
          h[k] = ->( value ) { "<strong>#{value}</strong>" }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
auto_error-0.0.5 lib/auto_error/config.rb