Method: Rbind::RNamespace#const

Defined in:
lib/rbind/core/rnamespace.rb

#const(name, raise_ = true, search_owner = true) ⇒ Object

Raises:

  • (RuntimeError)


153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/rbind/core/rnamespace.rb', line 153

def const(name,raise_ = true,search_owner = true)
    hash = @consts.merge(enum_hash)
    c = if hash.has_key?(name)
            hash[name]
        else
            if !!(ns = RBase.namespace(name))
                t = type(ns,false)
                t.const(RBase.basename(name),false,false) if t
            end
        end
    c ||= begin
              used_namespaces.each do |ns|
                  c = ns.const(name,false,false)
                  break if c
              end
              c
          end
    c ||= if search_owner && owner
              owner.const(name,false)
          end
    raise RuntimeError,"#{full_name} has no const called #{name}" if raise_ && !c
    c
end