Module: Yummi::Helpers
- Defined in:
- lib/yummi.rb
Class Method Summary collapse
Class Method Details
.load_resource(name, params = {:from => ''}) ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/yummi.rb', line 242 def self.load_resource name, params = {:from => ''} from = params[:from].to_s [ File.join(File.('~/.yummi'), from), File.join(File.dirname(__FILE__), 'yummi', from) ].each do |path| file = File.join(path, "#{name}.yaml") return YAML::load_file(file) if File.exist?(file) end raise Exception::new("Unable to load #{name}") end |
.symbolize_keys(hash) ⇒ Object
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/yummi.rb', line 254 def self.symbolize_keys hash hash.replace(hash.inject({}) do |h, (k, v)| v = symbolize_keys(v) if v.is_a? Hash if v.is_a? Array v.each do |e| if e.is_a? Hash symbolize_keys(e) end end end k = k.to_sym if k.respond_to? :to_sym h[k] = v h end) end |