Sha256: 8dd1482070e88139e1adf8a208bcb63a763b45e29cf97b7fbc494aaed93f7135

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 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::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

3 entries across 3 versions & 1 rubygems

Version Path
auto_error-0.0.12 lib/auto_error/config.rb
auto_error-0.0.10 lib/auto_error/config.rb
auto_error-0.0.9 lib/auto_error/config.rb