Class: Erbside::Context
- Inherits:
-
Object
- Object
- Erbside::Context
- Defined in:
- lib/erbside/context.rb
Overview
Tilling Context
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#initialize(file, resources = []) ⇒ Context
constructor
A new instance of Context.
- #method_missing(s) ⇒ Object
-
#render(text) ⇒ Object
Processes through erb.
- #root ⇒ Object
- #to_h ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(s) ⇒ Object
20 21 22 |
# File 'lib/erbside/context.rb', line 20 def method_missing(s) @metadata.send(s) end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
10 11 12 |
# File 'lib/erbside/context.rb', line 10 def @metadata end |
Instance Method Details
#render(text) ⇒ Object
Processes through erb.
35 36 37 38 39 40 41 |
# File 'lib/erbside/context.rb', line 35 def render(text) Dir.chdir(@directory) do erb = ERB.new(text) erb.filename = @filename.to_s erb.result(binding) end end |
#root ⇒ Object
25 26 27 |
# File 'lib/erbside/context.rb', line 25 def root .root end |
#to_h ⇒ Object
30 31 32 |
# File 'lib/erbside/context.rb', line 30 def to_h @metadata.to_h end |