beret 0.2.0 → 0.3.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 +8 -6
- data/lib/beret/block_set.rb +2 -2
- data/lib/beret/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: 6490a904f8d44b4742981355f88f276ffc6b15cf
|
4
|
+
data.tar.gz: 2f242277dc37205dfe6ea83831dd37e472fd5ff5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73920e909c96e1aecca8d5b1f5c7611ad8a2495e78a578f2a9dd7825ac8f7104f979af9464f9ee37c52a17397ce1ecc3d87d3cc083d34e3f6c6bff653a0a56ad
|
7
|
+
data.tar.gz: 6dc79c0ce717b81d84b67c23530de3ab3121cd2d296c638be8664e346c8d6f1ab3b97a653363bd161057fa75cc92bd1c635984913962353ba94a710468dd1a18
|
data/README.md
CHANGED
@@ -31,14 +31,16 @@ ck_json = "[{\"content\":{\"text\":\"This is some text.\"},\"type\":\"redactor\"
|
|
31
31
|
beret = Beret.new(ck_json)
|
32
32
|
|
33
33
|
# Finding values
|
34
|
-
beret.find(
|
35
|
-
beret.find(
|
36
|
-
beret.find(
|
37
|
-
beret.find(
|
34
|
+
beret.find(:photo_id) # => [<Beret::Result value="42">, <Beret::Result value="144">]
|
35
|
+
beret.find(:photo_id, in: [:image]) # => [<Beret::Result value="42">]
|
36
|
+
beret.find(:photo_id, in: [:avatar]) # => [<Beret::Result value="144">]
|
37
|
+
beret.find(:photo_id, in: [:some_other_block_type]) # => []
|
38
38
|
|
39
39
|
# In-place updating
|
40
|
-
beret.update(:
|
41
|
-
value
|
40
|
+
beret.update(:photo_id, in: [:image]) do |value|
|
41
|
+
# Transform the value any way you'd like here.
|
42
|
+
# In this example, we convert a plain old ID to a SGID
|
43
|
+
Image.find(value).to_sgid
|
42
44
|
end
|
43
45
|
|
44
46
|
# Retrieving JSON
|
data/lib/beret/block_set.rb
CHANGED
@@ -5,11 +5,11 @@ module Beret
|
|
5
5
|
@block_json = block_json
|
6
6
|
end
|
7
7
|
|
8
|
-
def find(field_name, options)
|
8
|
+
def find(field_name, options={})
|
9
9
|
Search.new(blocks, field_name, options).results
|
10
10
|
end
|
11
11
|
|
12
|
-
def update(field_name, options)
|
12
|
+
def update(field_name, options={})
|
13
13
|
results = find(field_name, options)
|
14
14
|
|
15
15
|
results.each do |result|
|
data/lib/beret/version.rb
CHANGED