Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use activesupport directly instead of copying parts of it.

  • Loading branch information...
commit b0f15a2da9d5e0368318620739ad0ec1067ab03c 1 parent fa9851b
Jason Voegele authored
Showing with 4 additions and 33 deletions.
  1. +1 −0  Rakefile
  2. +3 −33 lib/ehcache/extensions.rb
1  Rakefile
View
@@ -34,6 +34,7 @@ Jeweler::Tasks.new do |gemspec|
gemspec.files.exclude 'lib/ehcache_store.rb'
gemspec.files.exclude 'lib/active_support/**/*'
gemspec.files.exclude 'lib/ehcache/rails'
+ gemspec.add_dependency 'activesupport'
end
Jeweler::Tasks.new do |gemspec|
36 lib/ehcache/extensions.rb
View
@@ -1,3 +1,6 @@
+require 'active_support/core_ext/string/inflections'
+require 'active_support/core_ext/array/extract_options'
+
class Hash
# Merges self with another hash, recursively.
# This code was lovingly stolen from some random gem:
@@ -26,36 +29,3 @@ def deep_merge!(second)
end
end
end
-
-# The following were extracted from activesupport in order not to create a dependency.
-
-class Hash
- # By default, only instances of Hash itself are extractable.
- # Subclasses of Hash may implement this method and return
- # true to declare themselves as extractable. If a Hash
- # is extractable, Array#extract_options! pops it from
- # the Array when it is the last element of the Array.
- def extractable_options?
- instance_of?(Hash)
- end
-end
-
-class Array
- # Extracts options from a set of arguments. Removes and returns the last
- # element in the array if it's a hash, otherwise returns a blank hash.
- #
- # def options(*args)
- # args.extract_options!
- # end
- #
- # options(1, 2) # => {}
- # options(1, 2, :a => :b) # => {:a=>:b}
- def extract_options!
- if last.is_a?(Hash) && last.extractable_options?
- pop
- else
- {}
- end
- end
-end
-
Please sign in to comment.
Something went wrong with that request. Please try again.