model_view 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +6 -6
- data/lib/model_view/version.rb +1 -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: aef140793172f7e2692c3fb46cf86a5d9ee94acb
|
4
|
+
data.tar.gz: fbd1d07a10c07fd055db7e126d05112902b80d85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1eba489732401a4448576c68a076ab27a1af43b623108a65fec0056c2c4c6689823595027cce93f55e652427a5eb64db583d1c77a06d3362aa96dfa418a65d9
|
7
|
+
data.tar.gz: bb8f406b8de03109e1e93061776097b69bac01f6451cf6bd977979e22044420b0c6923ceb58ff4ee1d5d853018511e1ab26eb6b3531d0b14e59c2ae911139ac9
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@ ModelView let's you define views for your models in one place.
|
|
6
6
|
### Why ModelView?
|
7
7
|
|
8
8
|
At OfferZen, most of our rails models can be presented in al least two ways. For example, an Interview Request
|
9
|
-
is presented differently to a candidate than to a company. But, there
|
9
|
+
is presented differently to a candidate than to a company. But, there are also a lot of fields that get presented
|
10
10
|
the same to both candidates and companies. We found ourselves duplicating a lot of our serialisation code in our
|
11
11
|
controllers and the code started to get out of hand.
|
12
12
|
|
@@ -14,7 +14,7 @@ ModelView works with Rails, but Rails is definitely not a requirement
|
|
14
14
|
|
15
15
|
### How to use ModelView
|
16
16
|
|
17
|
-
1) Include the
|
17
|
+
1) Include the gem in your gemfile
|
18
18
|
```ruby
|
19
19
|
gem "model_view", '~> 0.1'
|
20
20
|
```
|
@@ -33,8 +33,8 @@ field :name
|
|
33
33
|
|
34
34
|
field(:first_name) { |person| person.name.split(' ').first }
|
35
35
|
|
36
|
-
field :is_current_user, context[:current_user] do |person|
|
37
|
-
person
|
36
|
+
field :is_current_user, context[:current_user] do |person, current_user|
|
37
|
+
person == current_user
|
38
38
|
end
|
39
39
|
```
|
40
40
|
4) Let ModelView serialise an instance
|
@@ -64,8 +64,8 @@ scope :demographics do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
scope :status do
|
67
|
-
field :is_current_user, context[:current_user] do |person|
|
68
|
-
person
|
67
|
+
field :is_current_user, context[:current_user] do |person, current_user|
|
68
|
+
person == current_user
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
data/lib/model_view/version.rb
CHANGED