nO_op 1.O.O → 1.O.O.1
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.
- data/History.txt +5 -0
- data/README.md +34 -0
- data/lib/nO_op.rb +4 -0
- data/spec/nO_op_spec.rb +19 -0
- metadata +4 -2
data/History.txt
CHANGED
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# What?
|
2
|
+
|
3
|
+
I think this question can be best answered by a few contrived examples of what real-world use might look like.
|
4
|
+
|
5
|
+
```
|
6
|
+
# This convoluted code makes sure that the @kind is "credit_card" or
|
7
|
+
# "purchase_order", and if it's not "credit_card", then the customer
|
8
|
+
# must not have a payment_method of "credit_card".
|
9
|
+
if [ 'credit_card', 'purchase_order' ].include?(@kind) && (@kind == 'credit_card' || current_user.customer.payment_method == 'purchase_order')
|
10
|
+
@order = ((@kind == 'credit_card') ? CreditCardOrder : PurchaseOrder).new(params[:order])
|
11
|
+
|
12
|
+
O_o
|
13
|
+
end
|
14
|
+
```
|
15
|
+
|
16
|
+
or
|
17
|
+
|
18
|
+
```
|
19
|
+
current_user.prelude_web_user.shipping_addresses.reject { |a| a.to_s.blank? }.sort_by(&:to_s).O_o.collect {|a| [ a.to_s, a.id ] }
|
20
|
+
```
|
21
|
+
|
22
|
+
I like to think of that second usage as a judgemental `tap`.
|
23
|
+
|
24
|
+
Also available:
|
25
|
+
|
26
|
+
* o_O
|
27
|
+
|
28
|
+
## Contributions
|
29
|
+
|
30
|
+
You want to contribute to this? Really? Y'know, you should check out my 'truthy' project, too.
|
31
|
+
|
32
|
+
## License
|
33
|
+
|
34
|
+
nO_op uses the MIT license. Read License.txt if you care.
|
data/lib/nO_op.rb
CHANGED
data/spec/nO_op_spec.rb
CHANGED
@@ -23,4 +23,23 @@ describe 'methods' do
|
|
23
23
|
obj.O_o.should == obj
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
it "should add an 'o_O' method" do
|
28
|
+
Object.new.should.respond_to(:o_O)
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "'o_O' method" do
|
32
|
+
it 'should not require arguments' do
|
33
|
+
lambda { Object.new.o_O }.should.not.raise(ArgumentError)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should return the calling object' do
|
37
|
+
obj = Object.new
|
38
|
+
obj.o_O.should == obj
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should be callable on its own' do
|
42
|
+
lambda { o_O }.should.not.raise
|
43
|
+
end
|
44
|
+
end
|
26
45
|
end
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nO_op
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 445
|
5
5
|
prerelease: 2
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- O
|
9
9
|
- O
|
10
|
-
|
10
|
+
- 1
|
11
|
+
version: 1.O.O.1
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Yossef Mendelssohn
|
@@ -45,6 +46,7 @@ extra_rdoc_files: []
|
|
45
46
|
files:
|
46
47
|
- License.txt
|
47
48
|
- History.txt
|
49
|
+
- README.md
|
48
50
|
- lib/nO_op.rb
|
49
51
|
- spec/helper.rb
|
50
52
|
- spec/nO_op_spec.rb
|