Module: RorHack::KernelHack

Included in:
Kernel
Defined in:
lib/ror_hack/kernel_hack.rb

Instance Method Summary collapse

Instance Method Details

#petty_eval(bind, str) ⇒ Object

将eval中数据绑定移动到前面,样式好看一些。



4
5
6
# File 'lib/ror_hack/kernel_hack.rb', line 4

def petty_eval(bind, str)
  eval str, bind
end

#yml_load_config(name, default_value = '66dc9e58b19ecc4ec538ea771b71b372') ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ror_hack/kernel_hack.rb', line 8

def yml_load_config(name, default_value='66dc9e58b19ecc4ec538ea771b71b372')
  name += '.yml' unless name.end_with?('.yml')
  if File.file?(File.join(Rails.root, '/config', name))
    result = YAML.load_file(File.join(Rails.root, '/config', name))
    if result.is_a? Array
      return result
    else
      return OpenStruct.new(result)
    end
  else
    if default_value == '66dc9e58b19ecc4ec538ea771b71b372'
      YAML.load_file(File.join(Rails.root, '/config', name))
    else
      return default_value
    end
  end
end