delegate_it 0.0.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -2
- data/lib/delegate_it/main.rb +1 -1
- data/lib/delegate_it/version.rb +1 -1
- data/spec/delegate_it/main_spec.rb +0 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f50eddfb21b4ce5194f165f8a54aa0c0289de12
|
4
|
+
data.tar.gz: 160a17d66a8b07abcd2b6d815c20f158d6f9c395
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 290e75c1e27cf94be088089cadf1c8364dd042edf8c57e30cfd1c7bcf095cbc4c9ba647f011fd4a8c452110a485db9355584f89a052bd5421985ef864723c7e2
|
7
|
+
data.tar.gz: 84782ae5584bbd95de9fed4d37c5b6bef3de28f958264a8e5855be9d97d14f1210c4efd661c742e5faa4f4aad9fac8ba48c96e682e5ab4b05994cfefa0e9524c
|
data/README.md
CHANGED
@@ -1,3 +1,41 @@
|
|
1
|
-
#
|
1
|
+
# Delegate it
|
2
2
|
|
3
|
-
|
3
|
+
delegate_it gem provides an easy way to use ActiveSupport like `delegate` method in your non Rails projects.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
In your Gemfile:
|
8
|
+
|
9
|
+
````ruby
|
10
|
+
gem 'delegate_it'
|
11
|
+
````
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```` ruby
|
16
|
+
class Offer
|
17
|
+
include DelegateIt
|
18
|
+
|
19
|
+
delegate :name, :description, to: :product
|
20
|
+
delegate :brand, to: :manufacturer, allow_nil: true
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def product
|
25
|
+
Struct.new(:name, :description)
|
26
|
+
.new('Great product', 'Awesome!')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
offer = Offer.new
|
31
|
+
offer.name # => 'Great product'
|
32
|
+
offer.description # => 'Awesome!'
|
33
|
+
offer.brand # => nil
|
34
|
+
|
35
|
+
````
|
36
|
+
|
37
|
+
### Supported options
|
38
|
+
|
39
|
+
`allow_nil: true` - if the delegate does not exist method call will return nil.
|
40
|
+
|
41
|
+
PRs are welcome.
|
data/lib/delegate_it/main.rb
CHANGED
data/lib/delegate_it/version.rb
CHANGED