Class: Garage::Docs::Example

Inherits:
Object
  • Object
show all
Defined in:
lib/garage/docs/example.rb

Class Method Summary collapse

Instance Method Summary collapse

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

#urlObject



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