Skip to content

Commit

Permalink
Merge pull request #44 from sferik/delegate_explicit_conversions
Browse files Browse the repository at this point in the history
Delegate explicit conversions to nil instead of defining them explicitly
  • Loading branch information
Avdi Grimm committed Jan 6, 2014
2 parents 7423689 + 85c195d commit 3ad13c6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
12 changes: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
env:
- TRAVIS=true
bundler_args: --without development
language: ruby
rvm:
- 2.0.0
- 2.1.0
- ruby-head
matrix:
allow_failures:
- rvm: ruby-head
fast_finish: true
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in naught.gemspec
gemspec

gem 'rake'

group :development do
gem 'guard'
gem 'guard-rspec'
gem 'guard-bundler'
end

group :test do
gem "libnotify"
gem 'coveralls', require: false
gem 'rspec', '~> 2.14'
end
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
require 'forwardable'
require 'naught/null_class_builder/command'

module Naught::NullClassBuilder::Commands
class DefineExplicitConversions < ::Naught::NullClassBuilder::Command
def call
defer do |subject|
subject.module_eval do
def to_s; ""; end
def to_i; 0; end
def to_f; 0.0; end
def to_c; 0.to_c; end
def to_r; 0.to_r; end
def to_a; []; end
def to_h; {}; end
extend Forwardable
def_delegators :nil, :to_a, :to_c, :to_f, :to_h, :to_i, :to_r, :to_s
end
end
end
Expand Down
5 changes: 0 additions & 5 deletions naught.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,4 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 2.14"
spec.add_development_dependency "guard"
spec.add_development_dependency "guard-rspec"
spec.add_development_dependency "guard-bundler"
end

0 comments on commit 3ad13c6

Please sign in to comment.