Sha256: 67c55b03680f3aa563b0b4ce319a933c8ceb7b74e1107eab2c60b42dc4f94146

Contents?: true

Size: 557 Bytes

Versions: 10

Compression:

Stored size: 557 Bytes

Contents

class Usher
  module Interface
    class Email

      def initialize(&blk)
        @routes = Usher.new(:delimiters => ['@', '-', '.'], :valid_regex => '[\+a-zA-Z0-9]+')
        instance_eval(&blk) if blk
      end

      def for(path, &block)
        @routes.add_route(path).to(block)
      end

      def reset!
        @routes.reset!
      end

      def act(email)
        response = @routes.recognize(email, email)
        if response.path
          response.path.route.destination.call(response.params_as_hash)
        end
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
usher-0.7.4 lib/usher/interface/email.rb
usher-0.7.3 lib/usher/interface/email.rb
usher-0.7.2 lib/usher/interface/email.rb
usher-0.7.1 lib/usher/interface/email.rb
usher-0.7.0 lib/usher/interface/email.rb
usher-0.6.8 lib/usher/interface/email.rb
usher-0.6.7 lib/usher/interface/email.rb
usher-0.6.6 lib/usher/interface/email.rb
usher-0.6.5 lib/usher/interface/email.rb
usher-0.6.4 lib/usher/interface/email.rb