Sha256: 5ee745aed874be3eace27f63f15bb4b0d325681355733c055fae9e090da6a499

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 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 = nil

    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.add_notifier :email, {}
        # 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

5 entries across 5 versions & 1 rubygems

Version Path
auto_error-0.0.18 lib/auto_error/config.rb
auto_error-0.0.16 lib/auto_error/config.rb
auto_error-0.0.15 lib/auto_error/config.rb
auto_error-0.0.14 lib/auto_error/config.rb
auto_error-0.0.13 lib/auto_error/config.rb