Sha256: 4420188d4af8673714a0b5de17c3efb8fa71f0f2b06b0858102b8d5fef978338

Contents?: true

Size: 598 Bytes

Versions: 6

Compression:

Stored size: 598 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.inject({}){|h,(k,v)| h[k]=v.to_s; h })
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
usher-0.6.3 lib/usher/interface/email.rb
usher-0.6.2 lib/usher/interface/email.rb
usher-0.6.1 lib/usher/interface/email.rb
usher-0.6.0 lib/usher/interface/email.rb
usher-0.5.13 lib/usher/interface/email.rb
usher-0.5.12 lib/usher/interface/email.rb