Class: Toto::Site::Context
- Includes:
- PageHelpers, Template
- Defined in:
- lib/toto.rb
Instance Method Summary collapse
-
#initialize(ctx = {}, config = {}, path = "/") ⇒ Context
constructor
A new instance of Context.
- #method_missing(m, *args, &blk) ⇒ Object
- #render(page, type) ⇒ Object
- #to_xml(page) ⇒ Object (also: #to_atom)
Methods included from PageHelpers
#archives, #articles, #import, #root, #title
Methods included from ConfigHelpers
Methods included from Template
Constructor Details
#initialize(ctx = {}, config = {}, path = "/") ⇒ Context
Returns a new instance of Context.
171 172 173 174 175 176 177 178 |
# File 'lib/toto.rb', line 171 def initialize ctx = {}, config = {}, path = "/" @config, @context, @path = config, ctx, path @articles = articles ctx.each do |k, v| (k) { ctx.instance_of?(Hash) ? v : ctx.send(k) } end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &blk) ⇒ Object
190 191 192 |
# File 'lib/toto.rb', line 190 def method_missing m, *args, &blk @context.respond_to?(m) ? @context.send(m) : super end |
Instance Method Details
#render(page, type) ⇒ Object
180 181 182 |
# File 'lib/toto.rb', line 180 def render page, type type == :html ? to_html(:layout, @config, &Proc.new { to_html page, @config }) : send(:"to_#{type}", :feed) end |