Class: Boss::PostGenerator
- Inherits:
-
Object
- Object
- Boss::PostGenerator
- Defined in:
- lib/boss/post_generator.rb
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(*args) ⇒ PostGenerator
constructor
A new instance of PostGenerator.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(*args) ⇒ PostGenerator
Returns a new instance of PostGenerator.
4 5 6 7 8 9 |
# File 'lib/boss/post_generator.rb', line 4 def initialize(*args) @html = "<%# This file was generated, please do not edit unless you are sure of what you're doing %>\n\n<% post ||= @post %>\n\n" yield.each do |elem| send elem end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/boss/post_generator.rb', line 20 def method_missing(method, *args) begin file = File.open("#{Boss::Engine.root}/app/views/boss/posts/_#{method.to_s}.html.erb", "rb") @html += file.read @html += "\n" file.close rescue super end end |