nil_or 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +40 -0
  3. data/lib/nil_or.rb +2 -2
  4. data/nil_or.gemspec +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a5c9ed505c1f36bbfaf2e040c111ccba5ea4b5b
4
- data.tar.gz: f5867290848fd7759065c00fbf0a87392d380953
3
+ metadata.gz: c1a0af38e63fb8dc2790570ee5297eb7ad07a161
4
+ data.tar.gz: 2b6f8cfe4040142bf4273c254915781b1747266e
5
5
  SHA512:
6
- metadata.gz: f4c5b30013697364e79de1b24e4fed4849f2aaa1f17d2966875cbdd7861f753dcac2fb9944079dc799d34ab72f85e8dcb061150d1bc398d84ec557483dc5edb3
7
- data.tar.gz: 50a939a9bc87ff0e8c77edf63a394ac31f08f520e24cdfd247623717c01164ac4b8a5622a51ef0d5a671308348a6605d289616800816db680a52a36a487ec67a
6
+ metadata.gz: ad1a4dcfec50cfe3d85ea58f53b14f3bc6f32165d1805df0a8ddee2a704b623d7b820908a1a6c9f079aec80e54d4ab64acf9f3358af42b411849ef1093159676
7
+ data.tar.gz: 48a0bba734760dd9df498da05b14c296835867d4e26d0defeacad8d3836e48d87ce9e0f477942e279f0c5ce4e943c6781f9724ddbea9ee049d2be8c06faf7fda
data/README.md CHANGED
@@ -1 +1,41 @@
1
1
  # nil_or
2
+
3
+ Delegates methods to the target unless nil.
4
+
5
+ ## Getting started
6
+
7
+ $ gem install nil_or
8
+
9
+ Or in your Gemfile:
10
+
11
+ gem "nil_or"
12
+
13
+ ## Usage
14
+
15
+ When am I going to need it? Instead of writing:
16
+
17
+ date_of_birth = params[:date_of_birth] ? params[:date_of_birth].to_date : nil
18
+
19
+ Write:
20
+
21
+ date_of_birth = params[:date_of_birth].nil_or.to_date
22
+
23
+ When x is not nil:
24
+
25
+ x = 5
26
+ x.nil_or.to_s
27
+ => "5"
28
+ x.nil_or + 2
29
+ => 7
30
+ x.nil_or.times { |i| puts i }
31
+ ...
32
+
33
+ But when it is nil:
34
+
35
+ x = nil
36
+ x.nil_or.to_s
37
+ => nil
38
+ x.nil_or + 2
39
+ => nil
40
+ x.nil_or.shakalaka(1, 2) { does_nothing }
41
+ => nil
data/lib/nil_or.rb CHANGED
@@ -17,7 +17,7 @@ module NilOr
17
17
  end
18
18
  end
19
19
 
20
- class BasicObject
21
- include ::NilOr
20
+ class Object
21
+ include NilOr
22
22
  end
23
23
 
data/nil_or.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "nil_or"
6
- s.version = "0.0.1"
6
+ s.version = "1.0.0"
7
7
  s.authors = ["Oded Niv"]
8
8
  s.email = ["oded.niv@gmail.com"]
9
9
  s.homepage = "https://github.com/toplex/nil_or"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nil_or
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oded Niv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-28 00:00:00.000000000 Z
11
+ date: 2013-04-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Delegates methods to the object or returns nil.
14
14
  email: