Class: Usher::Interface::Email

Inherits:
Object
  • Object
show all
Defined in:
lib/usher/interface/email.rb

Instance Method Summary collapse

Constructor Details

#initialize(&blk) ⇒ Email

Returns a new instance of Email.



5
6
7
8
# File 'lib/usher/interface/email.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.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.rb', line 10

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

#reset!Object



14
15
16
# File 'lib/usher/interface/email.rb', line 14

def reset!
  @routes.reset!
end