Module: Mcmire::ArOoSelect

Defined in:
lib/mcmire/ar_oo_select.rb,
lib/mcmire/ar_oo_select/ar_ext.rb,
lib/mcmire/ar_oo_select/version.rb

Defined Under Namespace

Modules: ArExt

Constant Summary collapse

VERSION =
"0.5.0"

Class Method Summary collapse

Class Method Details

.open_hashObject



3
4
5
6
7
8
9
10
# File 'lib/mcmire/ar_oo_select.rb', line 3

def self.open_hash
  @open_hash ||= try_loading(
    ['mash', :Mash],
    ['facets/openobject', :OpenObject],
    ['openhash', :OpenHash],
    ['ostruct' => :OpenStruct]
  )
end

.try_loading(*libs) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mcmire/ar_oo_select.rb', line 11

def self.try_loading(*libs)
  klass = nil
  libs.each do |path, sym|
    begin
      require path
      klass = Object.const_get(sym)
      break
    rescue LoadError
    end
  end
  klass
end