Skip to content

Commit

Permalink
Replace custom Twitter::NullObject with Naught
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jan 26, 2014
1 parent 7732ffc commit bc3990e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 112 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end

require 'yardstick/rake/verify'
Yardstick::Rake::Verify.new do |verify|
verify.threshold = 59.7
verify.threshold = 59.8
end

task :default => [:spec, :rubocop, :verify_measurements]
28 changes: 8 additions & 20 deletions lib/twitter/null_object.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
require 'forwardable'
require 'naught'

module Twitter
class NullObject
extend Forwardable
def_instance_delegators :nil, :nil?, :to_a, :to_c, :to_c, :to_f, :to_h,
:to_i, :to_r, :to_s
alias_method :to_ary, :to_a
alias_method :to_str, :to_s
NullObject = Naught.build do |config|
config.black_hole
config.define_explicit_conversions
config.define_implicit_conversions
config.predicates_return false

# @return [Twitter::NullObject] This method always returns self.
def method_missing(*args)
self
end

# @return [TrueClass] This method always returns true.
def respond_to?(method_name, include_private = false)
def nil?
true
end if RUBY_VERSION < '1.9'

# @return [TrueClass] This method always returns true.
def respond_to_missing?(method_name, include_private = false)
true
end if RUBY_VERSION >= '1.9'
end
end
end
2 changes: 1 addition & 1 deletion spec/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

SimpleCov.start do
add_filter '/spec/'
minimum_coverage(99.37)
minimum_coverage(99.42)
end

require 'twitter'
Expand Down
90 changes: 0 additions & 90 deletions spec/twitter/null_object_spec.rb

This file was deleted.

1 change: 1 addition & 0 deletions twitter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'http_parser.rb', '~> 0.6.0'
spec.add_dependency 'json', '~> 1.8'
spec.add_dependency 'memoizable', '~> 0.4.0'
spec.add_dependency 'naught', '~> 1.0'
spec.add_dependency 'simple_oauth', '~> 0.2.0'
spec.add_development_dependency 'bundler', '~> 1.0'
spec.authors = ['Erik Michaels-Ober', 'John Nunemaker', 'Wynn Netherland', 'Steve Richert', 'Steve Agalloco']
Expand Down

0 comments on commit bc3990e

Please sign in to comment.