Module: Steam::Java::AutoDefine

Included in:
Steam::Java
Defined in:
lib/steam/java.rb

Overview

Instance Method Summary collapse

Instance Method Details

#const_set_nested(full_name, const) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/steam/java.rb', line 11

def const_set_nested(full_name, const)
  name = pop_name(full_name)
  if full_name.empty? && !const_defined?(name)
    const_set(name, const)
  else
    const_set(name, Module.new { extend AutoDefine }) unless const_defined?(name)
    const_get(name).const_set_nested(full_name, const) unless full_name.empty?
  end
end

#pop_name(string) ⇒ Object



21
22
23
24
25
# File 'lib/steam/java.rb', line 21

def pop_name(string)
  name, *rest = string.split('::')
  string.replace(rest.join('::'))
  name
end