Class: Alephant::Views::Preview
- Inherits:
-
Mustache
- Object
- Mustache
- Alephant::Views::Preview
show all
- Defined in:
- lib/alephant/views/preview.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(regions, template_location) ⇒ Preview
Returns a new instance of Preview.
8
9
10
11
|
# File 'lib/alephant/views/preview.rb', line 8
def initialize(regions, template_location)
@regions=regions
self.template_file = template_location
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
17
18
19
20
|
# File 'lib/alephant/views/preview.rb', line 17
def method_missing(name, *args, &block)
return super unless respond_to? name.to_s
region @regions[name.to_s]
end
|
Instance Attribute Details
#regions ⇒ Object
Returns the value of attribute regions.
6
7
8
|
# File 'lib/alephant/views/preview.rb', line 6
def regions
@regions
end
|
Instance Method Details
#region(components) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/alephant/views/preview.rb', line 26
def region(components)
if components.kind_of?(Array)
components.join
else
components
end
end
|
#respond_to?(method) ⇒ Boolean
22
23
24
|
# File 'lib/alephant/views/preview.rb', line 22
def respond_to?(method)
valid_regions.include? method.to_s
end
|
#static_host ⇒ Object
13
14
15
|
# File 'lib/alephant/views/preview.rb', line 13
def static_host
'localhost:8000'
end
|
#valid_regions ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/alephant/views/preview.rb', line 34
def valid_regions
self.template.tokens.find_all { |token|
token.is_a?(Array) && token[0] == :mustache
}.map{ |token|
token[2][2][0].to_s
}
end
|