instance method local_constants

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

local_constants()

Returns the constants that have been defined locally by this object and not in an ancestor. This method is exact if running under Ruby 1.9. In previous versions it may miss some constants if their definition in some ancestor is identical to their definition in the receiver.

Source
# File activesupport/lib/active_support/core_ext/module/introspection.rb, line 65
        def local_constants
          inherited = {}

          ancestors.each do |anc|
            next if anc == self
            anc.constants.each { |const| inherited[const] = anc.const_get(const) }
          end

          constants.select do |const|
            !inherited.key?(const) || inherited[const].object_id != const_get(const).object_id
          end
        end

Defined in activesupport/lib/active_support/core_ext/module/introspection.rb line 65 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::CoreExtensions::Module

Type at least 2 characters to search.

↑↓ navigate · open · esc close