Sha256: be3ad237cbd942efd4dbe44c76cb7504e7b49be287a6cf16933d42004c20ed5d

Contents?: true

Size: 660 Bytes

Versions: 5

Compression:

Stored size: 660 Bytes

Contents

module Postini

  # Mixin with a method decorator that prevents calls from being made
  # if the library is not properly configured.
  module ConfigurationCheck

    def self.included( base )
      base.extend( ClassMethods )
    end

    module ClassMethods

      def requires_configured( method_name )
        class_eval <<-EOF, __FILE__, __LINE__
          alias #{method_name}_original #{method_name}
          def #{method_name}( *args )
            raise Postini::NotConfigured, "Cannot call #{method_name} if not configured" unless Postini.configured?

            #{method_name}_original( *args )
          end
        EOF
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
kennethkalmer-postini-0.1.0 lib/postini/configuration_check.rb
postini-0.2.0 lib/postini/configuration_check.rb
postini-0.2.0pre lib/postini/configuration_check.rb
postini-0.1.1 lib/postini/configuration_check.rb
postini-0.1.0 lib/postini/configuration_check.rb