Class: Module

Inherits:
Object show all
Defined in:
lib/card/core_ext.rb

Constant Summary collapse

RUBY_VERSION_18 =
!!(RUBY_VERSION =~ /^1\.8/)

Instance Method Summary collapse

Instance Method Details

#const_get_if_defined(const) ⇒ Object



44
45
46
47
# File 'lib/card/core_ext.rb', line 44

def const_get_if_defined const
  args = RUBY_VERSION_18 ? [const] : [const, false]
  const_get *args if const_defined? *args
end

#const_get_or_set(const) ⇒ Object



49
50
51
# File 'lib/card/core_ext.rb', line 49

def const_get_or_set const
  const_get_if_defined(const) || const_set(const, yield)
end