Class: MountDoc::Document
- Inherits:
-
Object
- Object
- MountDoc::Document
- Defined in:
- lib/mount_doc/document.rb
Instance Attribute Summary collapse
-
#doc_object ⇒ Object
readonly
Returns the value of attribute doc_object.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type, name) ⇒ Document
constructor
A new instance of Document.
- #load_controller(name) ⇒ Object
- #load_file(type = @type, name = @name) ⇒ Object
- #load_model(name) ⇒ Object
Constructor Details
#initialize(type, name) ⇒ Document
Returns a new instance of Document.
9 10 11 12 13 14 |
# File 'lib/mount_doc/document.rb', line 9 def initialize(type, name) @type = type @name = name load_file end |
Instance Attribute Details
#doc_object ⇒ Object (readonly)
Returns the value of attribute doc_object.
7 8 9 |
# File 'lib/mount_doc/document.rb', line 7 def doc_object @doc_object end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/mount_doc/document.rb', line 7 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/mount_doc/document.rb', line 7 def type @type end |
Instance Method Details
#load_controller(name) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/mount_doc/document.rb', line 25 def load_controller(name) controller_name = name.gsub('::', '/').camelize + 'Controller' file_path = File.join(::Rails.root, 'app/controllers', "#{controller_name.underscore}.rb") YARD.parse(file_path) @doc_object = P(controller_name) end |
#load_file(type = @type, name = @name) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/mount_doc/document.rb', line 16 def load_file(type = @type, name = @name) case type when :controller load_controller(name) when :model load_model(name) end end |
#load_model(name) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/mount_doc/document.rb', line 32 def load_model(name) model_name = name.gsub('::', '/').camelize file_path = File.join(::Rails.root, 'app/models', "#{model_name.underscore}.rb") YARD.parse(file_path) @doc_object = P(model_name) end |