Class: Usher::Interface::EmailInterface
- Inherits:
-
Object
- Object
- Usher::Interface::EmailInterface
- Defined in:
- lib/usher/interface/email_interface.rb
Instance Method Summary collapse
- #act(email) ⇒ Object
- #for(path, &block) ⇒ Object
-
#initialize(&blk) ⇒ EmailInterface
constructor
A new instance of EmailInterface.
- #reset! ⇒ Object
Constructor Details
#initialize(&blk) ⇒ EmailInterface
Returns a new instance of EmailInterface.
5 6 7 8 |
# File 'lib/usher/interface/email_interface.rb', line 5 def initialize(&blk) @routes = Usher.new(:delimiters => ['@', '-', '.'], :valid_regex => '[\+a-zA-Z0-9]+') instance_eval(&blk) if blk end |
Instance Method Details
#act(email) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/usher/interface/email_interface.rb', line 18 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 |
#for(path, &block) ⇒ Object
10 11 12 |
# File 'lib/usher/interface/email_interface.rb', line 10 def for(path, &block) @routes.add_route(path).to(block) end |
#reset! ⇒ Object
14 15 16 |
# File 'lib/usher/interface/email_interface.rb', line 14 def reset! @routes.reset! end |