Class: Garage::Docs::Example
- Inherits:
-
Object
- Object
- Garage::Docs::Example
- Defined in:
- lib/garage/docs/example.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(resource, controller) ⇒ Example
constructor
A new instance of Example.
- #url ⇒ Object
Constructor Details
#initialize(resource, controller) ⇒ Example
Returns a new instance of Example.
10 11 12 |
# File 'lib/garage/docs/example.rb', line 10 def initialize(resource, controller) @resource, @controller = resource, controller end |
Class Method Details
.build_all(controller, examples) ⇒ Object
4 5 6 7 8 |
# File 'lib/garage/docs/example.rb', line 4 def self.build_all(controller, examples) examples.compact.map do |resource| new(resource, controller) end end |
Instance Method Details
#url ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/garage/docs/example.rb', line 14 def url if @resource.is_a?(String) @resource elsif @resource.respond_to?(:to_proc) @resource.to_proc.call(@controller.main_app) else @resource.represent! @resource.link_path_for(:self) end end |