Class: MrMime::UrlResolver

Inherits:
Object
  • Object
show all
Defined in:
app/models/mr_mime/url_resolver.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ UrlResolver

Returns a new instance of UrlResolver.



9
10
11
12
13
# File 'app/models/mr_mime/url_resolver.rb', line 9

def initialize(url, options = {})
  @url = evaluate(url, *options[:args])
  @context = options[:context]
  @default = options[:default]
end

Class Method Details

.resolve(*args) ⇒ Object



5
6
7
# File 'app/models/mr_mime/url_resolver.rb', line 5

def self.resolve(*args)
  new(*args).resolve
end

Instance Method Details

#resolveObject



15
16
17
18
19
20
21
# File 'app/models/mr_mime/url_resolver.rb', line 15

def resolve
  case
  when method_name? then main_app.send(url)
  when url_name?    then url
  else default
  end
end