lib/method_doc.rb in rapi_doc-0.1.2 vs lib/method_doc.rb in rapi_doc-0.2.1
- old
+ new
@@ -1,13 +1,14 @@
module RapiDoc
# This class holds methods about a doc.
class MethodDoc
- attr_accessor :scope, :content, :request, :response, :code
+ attr_accessor :scope, :content, :request, :response, :code, :outputs, :variables
def initialize(type)
@scope = type
@variables = []
+ @outputs = []
@content = ""
@code = ""
@request = ""
@response = ""
end
@@ -18,11 +19,24 @@
@variables << value
return
end
eval("@#{name}= \"#{value}\"")
+ self.class.class_eval { attr_accessor name.to_sym }
end
-
+
+ def add_output(name, value)
+ if name == 'output'
+ @outputs << eval("{#{value}: ''}")
+ return
+ end
+ end
+
+ def append_output(value)
+ last_output_key = @outputs.last.keys[0]
+ @outputs.last[last_output_key] += ERB::Util.html_escape(value)
+ end
+
def get_binding
binding
end
end
end
\ No newline at end of file