Class: AegisNet::Sitemapper::Loader
- Inherits:
-
Object
- Object
- AegisNet::Sitemapper::Loader
- Defined in:
- lib/sitemapper/loader.rb
Class Method Summary collapse
-
.load_config ⇒ Object
Loads the sitemap configuration from Rails.root/config/sitemap.yml.
-
.proc_loader(string, *args) ⇒ Object
Interprets
string
as Ruby code representing a Proc and exectutes it.
Class Method Details
.load_config ⇒ Object
Loads the sitemap configuration from Rails.root/config/sitemap.yml
13 14 15 16 17 |
# File 'lib/sitemapper/loader.rb', line 13 def self.load_config # TODO verify file integrity erb = ERB.new(File.read(AegisNet::Sitemapper.sitemap_file)) AegisNet::Sitemapper.configuration ||= HashWithIndifferentAccess.new(YAML.load(StringIO.new(erb.result))) end |
.proc_loader(string, *args) ⇒ Object
Interprets string
as Ruby code representing a Proc and exectutes it.
Parameters
-
string
: Ruby (Proc) code to be executed
All other arguments will be passed to the Proc
Examples
AegisNet::Sitemapper::Loader.proc_loader('Proc.new{"foo"}')
=> "foo"
proc_str = 'Proc.new{|n| n}'
AegisNet::Sitemapper::Loader.proc_loader(proc_str, "hello world")
=> "hello world"
32 33 34 35 |
# File 'lib/sitemapper/loader.rb', line 32 def self.proc_loader(string, *args) # TODO lambdas eval(string).call(*args) end |