diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module')
5 files changed, 10 insertions, 102 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/anonymous.rb b/activesupport/lib/active_support/core_ext/module/anonymous.rb index 3982c9c586..0a9e791030 100644 --- a/activesupport/lib/active_support/core_ext/module/anonymous.rb +++ b/activesupport/lib/active_support/core_ext/module/anonymous.rb @@ -1,5 +1,3 @@ -require 'active_support/core_ext/object/blank' - class Module # A module may or may not have a name. # @@ -7,7 +5,7 @@ class Module # M.name # => "M" # # m = Module.new - # m.name # => "" + # m.name # => nil # # A module gets a name when it is first assigned to a constant. Either # via the +module+ or +class+ keyword or by an explicit assignment: @@ -17,8 +15,6 @@ class Module # m.name # => "M" # def anonymous? - # Uses blank? because the name of an anonymous class is an empty - # string in 1.8, and nil in 1.9. - name.blank? + name.nil? end end diff --git a/activesupport/lib/active_support/core_ext/module/introspection.rb b/activesupport/lib/active_support/core_ext/module/introspection.rb index c08ad251dd..1893a9cfa6 100644 --- a/activesupport/lib/active_support/core_ext/module/introspection.rb +++ b/activesupport/lib/active_support/core_ext/module/introspection.rb @@ -57,27 +57,8 @@ class Module parents end - if RUBY_VERSION < '1.9' - # 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. - 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 - else - def local_constants #:nodoc: - constants(false) - end + def local_constants #:nodoc: + constants(false) end # Returns the names of the constants defined locally rather than the diff --git a/activesupport/lib/active_support/core_ext/module/method_names.rb b/activesupport/lib/active_support/core_ext/module/method_names.rb deleted file mode 100644 index 2eb40a83ab..0000000000 --- a/activesupport/lib/active_support/core_ext/module/method_names.rb +++ /dev/null @@ -1,14 +0,0 @@ -class Module - if instance_methods[0].is_a?(Symbol) - def instance_method_names(*args) - instance_methods(*args).map(&:to_s) - end - - def method_names(*args) - methods(*args).map(&:to_s) - end - else - alias_method :instance_method_names, :instance_methods - alias_method :method_names, :methods - end -end
\ No newline at end of file diff --git a/activesupport/lib/active_support/core_ext/module/qualified_const.rb b/activesupport/lib/active_support/core_ext/module/qualified_const.rb index d1a0ee2f83..8adf050b6b 100644 --- a/activesupport/lib/active_support/core_ext/module/qualified_const.rb +++ b/activesupport/lib/active_support/core_ext/module/qualified_const.rb @@ -23,26 +23,14 @@ end # Object.const_get("::String") raises NameError and so does qualified_const_get. #++ class Module - if method(:const_defined?).arity == 1 - def qualified_const_defined?(path) - QualifiedConstUtils.raise_if_absolute(path) - - QualifiedConstUtils.names(path).inject(self) do |mod, name| - return unless mod.const_defined?(name) - mod.const_get(name) - end - return true - end - else - def qualified_const_defined?(path, search_parents=true) - QualifiedConstUtils.raise_if_absolute(path) + def qualified_const_defined?(path, search_parents=true) + QualifiedConstUtils.raise_if_absolute(path) - QualifiedConstUtils.names(path).inject(self) do |mod, name| - return unless mod.const_defined?(name, search_parents) - mod.const_get(name) - end - return true + QualifiedConstUtils.names(path).inject(self) do |mod, name| + return unless mod.const_defined?(name, search_parents) + mod.const_get(name) end + return true end def qualified_const_get(path) diff --git a/activesupport/lib/active_support/core_ext/module/synchronization.rb b/activesupport/lib/active_support/core_ext/module/synchronization.rb deleted file mode 100644 index ed16c2f71b..0000000000 --- a/activesupport/lib/active_support/core_ext/module/synchronization.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'thread' -require 'active_support/core_ext/module/aliasing' -require 'active_support/core_ext/array/extract_options' - -class Module - # Synchronize access around a method, delegating synchronization to a - # particular mutex. A mutex (either a Mutex, or any object that responds to - # #synchronize and yields to a block) must be provided as a final :with option. - # The :with option should be a symbol or string, and can represent a method, - # constant, or instance or class variable. - # Example: - # class SharedCache - # @@lock = Mutex.new - # def expire - # ... - # end - # synchronize :expire, :with => :@@lock - # end - def synchronize(*methods) - options = methods.extract_options! - unless options.is_a?(Hash) && with = options[:with] - raise ArgumentError, "Synchronization needs a mutex. Supply an options hash with a :with key as the last argument (e.g. synchronize :hello, :with => :@mutex)." - end - - methods.each do |method| - aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1 - - if method_defined?("#{aliased_method}_without_synchronization#{punctuation}") - raise ArgumentError, "#{method} is already synchronized. Double synchronization is not currently supported." - end - - module_eval(<<-EOS, __FILE__, __LINE__ + 1) - def #{aliased_method}_with_synchronization#{punctuation}(*args, &block) # def expire_with_synchronization(*args, &block) - #{with}.synchronize do # @@lock.synchronize do - #{aliased_method}_without_synchronization#{punctuation}(*args, &block) # expire_without_synchronization(*args, &block) - end # end - end # end - EOS - - alias_method_chain method, :synchronization - end - end -end |