Class: ActiveLoader::ContentLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/active_loader/content_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ContentLoader

Returns a new instance of ContentLoader.



5
6
7
# File 'lib/active_loader/content_loader.rb', line 5

def initialize(path)
  @path = path
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/active_loader/content_loader.rb', line 9

def call
  return default_content unless path

  if url?
    require "http"
    HTTP.get(path).to_s
  elsif file?
    IO.read(path)
  else
    path
  end
end