Skip to content
Browse files

stop extending Object, use ActiveSupport instead

  • Loading branch information...
1 parent a62d321 commit 0c67bba0e71a62c981b101cf1085f37d44c86cbd @shime shime committed Jan 7, 2013
Showing with 3 additions and 74 deletions.
  1. +1 −0 Gemfile.lock
  2. +1 −0 airbrake.gemspec
  3. +1 −1 lib/airbrake.rb
  4. +0 −73 lib/airbrake/extensions/blank.rb
View
1 Gemfile.lock
@@ -2,6 +2,7 @@ PATH
remote: .
specs:
airbrake (3.1.6)
+ activesupport
builder
GEM
View
1 airbrake.gemspec
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
s.test_files = Dir.glob("{test,spec,features}/**/*")
s.add_runtime_dependency("builder")
+ s.add_runtime_dependency("activesupport")
s.add_development_dependency("bourne", ">= 1.0")
s.add_development_dependency("cucumber-rails","~> 1.1.1")
View
2 lib/airbrake.rb
@@ -6,7 +6,7 @@
require 'net/http'
require 'net/https'
require 'rubygems'
-require 'airbrake/extensions/blank'
+require 'active_support/core_ext/object/blank'
require 'airbrake/version'
require 'airbrake/configuration'
require 'airbrake/notice'
View
73 lib/airbrake/extensions/blank.rb
@@ -1,73 +0,0 @@
-# stolen from ActiveSupport
-
-class Object
- unless method_defined?(:blank?)
- def blank?
- respond_to?(:empty?) ? empty? : !self
- end
- end
-
- unless method_defined?(:present?)
- def present?
- !blank?
- end
- end
-
- unless method_defined?(:presence)
- def presence
- self if present?
- end
- end
-end
-
-class NilClass
- unless method_defined?(:blank?)
- def blank?
- true
- end
- end
-end
-
-class FalseClass
- unless method_defined?(:blank?)
- def blank?
- true
- end
- end
-end
-
-class TrueClass
- unless method_defined?(:blank?)
- def blank?
- false
- end
- end
-end
-
-class Array
- unless method_defined?(:blank?)
- alias_method :blank?, :empty?
- end
-end
-
-class Hash
- unless method_defined?(:blank?)
- alias_method :blank?, :empty?
- end
-end
-
-class String
- unless method_defined?(:blank?)
- def blank?
- self !~ /[^[:space:]]/
- end
- end
-end
-
-class Numeric
- unless method_defined?(:blank?)
- def blank?
- false
- end
- end
-end

5 comments on commit 0c67bba

@grosser

any chance to have e.g. Airbrake.blank?(item) and have all the logic live in there ?

@shime
shime commented on 0c67bba Jan 20, 2013

@grosser yes, I've decided to put it back. The reason for removal was to minimize the runtime dependencies, but I now think it was a silly decision since this gem is meant to be used mostly in Rails applications.

Why would you want Airbrake.blank? instead of ActiveSupport's helpers?

@grosser

Just an idea how to have nice helpers but not extends Object or require active_support,
been working on a small project that uses airbrake but not active_support, no big deal though :)

@shime
shime commented on 0c67bba Jan 20, 2013

@grosser 👍 thanks for clarification!

@dwradcliffe

@shime So to clarify, is this staying like this or changing back? This breaks older active_support uses.

Please sign in to comment.
Something went wrong with that request. Please try again.