Module: Matryoshka::Document
- Defined in:
- lib/matryoshka/document.rb
Defined Under Namespace
Classes: Delegate, Html, Unknown
Class Method Summary
collapse
Class Method Details
.detect(method, matcher) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/matryoshka/document.rb', line 13
def self.detect(method,matcher)
document_classes.each do |klass|
klass.send(method).each do |detection_test|
if matcher =~ Regexp.new(Regexp.escape(detection_test))
return klass
end
end
end
false
end
|
.detect_handler(env) ⇒ Object
3
4
5
6
7
8
9
10
11
|
# File 'lib/matryoshka/document.rb', line 3
def self.detect_handler(env)
= env['HTTP_ACCEPT']
request_path = env['REQUEST_URI']
detect_using_extention(request_path) or
detect_using_accepts()
end
|
.detect_using_accepts(accepts_header) ⇒ Object
30
31
32
|
# File 'lib/matryoshka/document.rb', line 30
def self.detect_using_accepts()
detect :accepts,
end
|
.detect_using_extention(path) ⇒ Object
26
27
28
|
# File 'lib/matryoshka/document.rb', line 26
def self.detect_using_extention(path)
detect :extentions, File.extname(path)
end
|
.document_classes ⇒ Object
34
35
36
37
38
39
|
# File 'lib/matryoshka/document.rb', line 34
def self.document_classes
constants.collect do |const|
klass = const_get(const)
klass if klass.kind_of?(Class)
end.compact
end
|