contentstack 0.6.1 → 0.6.3
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.
- checksums.yaml +4 -4
- data/.github/workflows/codeql-analysis.yml +68 -68
- data/.github/workflows/jira.yml +28 -0
- data/.github/workflows/release-gem.yml +31 -0
- data/.github/workflows/sast-scan.yml +10 -10
- data/.github/workflows/sca-scan.yml +15 -13
- data/.github/workflows/secrets-scan.yml +10 -10
- data/.gitignore +11 -11
- data/.yardopts +6 -6
- data/CHANGELOG.md +114 -78
- data/CODEOWNERS +1 -1
- data/CODE_OF_CONDUCT.md +73 -73
- data/Gemfile +2 -2
- data/Gemfile.lock +76 -77
- data/LICENSE.txt +21 -21
- data/README.md +197 -197
- data/SECURITY.md +27 -27
- data/contentstack.gemspec +29 -29
- data/lib/contentstack/api.rb +191 -212
- data/lib/contentstack/asset.rb +68 -68
- data/lib/contentstack/asset_collection.rb +27 -27
- data/lib/contentstack/client.rb +91 -91
- data/lib/contentstack/content_type.rb +53 -53
- data/lib/contentstack/entry.rb +221 -221
- data/lib/contentstack/entry_collection.rb +44 -44
- data/lib/contentstack/error.rb +6 -6
- data/lib/contentstack/query.rb +653 -653
- data/lib/contentstack/region.rb +5 -5
- data/lib/contentstack/sync_result.rb +29 -29
- data/lib/contentstack/version.rb +2 -2
- data/lib/contentstack.rb +31 -31
- data/lib/util.rb +110 -110
- data/rakefile.rb +3 -3
- data/spec/asset_collection_spec.rb +15 -15
- data/spec/asset_spec.rb +47 -47
- data/spec/content_type_spec.rb +80 -80
- data/spec/contentstack_spec.rb +38 -38
- data/spec/entry_collection_spec.rb +41 -41
- data/spec/entry_spec.rb +101 -101
- data/spec/fixtures/asset.json +1 -1
- data/spec/fixtures/asset_collection.json +1 -1
- data/spec/fixtures/category_content_type.json +1 -1
- data/spec/fixtures/category_entry.json +1 -1
- data/spec/fixtures/category_entry_collection.json +1 -1
- data/spec/fixtures/category_entry_collection_without_count.json +1 -1
- data/spec/fixtures/content_types.json +1 -1
- data/spec/fixtures/product_entry.json +1 -1
- data/spec/fixtures/product_entry_collection.json +1 -1
- data/spec/fixtures/sync_init.json +2974 -2974
- data/spec/query_spec.rb +205 -205
- data/spec/spec_helper.rb +180 -180
- data/spec/sync_spec.rb +26 -26
- metadata +7 -17
data/lib/contentstack/entry.rb
CHANGED
@@ -1,222 +1,222 @@
|
|
1
|
-
require 'active_support/core_ext'
|
2
|
-
require 'util'
|
3
|
-
|
4
|
-
module Contentstack
|
5
|
-
class Entry
|
6
|
-
using Utility
|
7
|
-
attr_reader :fields, :content_type, :uid, :owner, :query, :schema, :content_type
|
8
|
-
def initialize(attrs, content_type_uid=nil)
|
9
|
-
setup(attrs, content_type_uid)
|
10
|
-
end
|
11
|
-
|
12
|
-
# Get entries from the specified locale.
|
13
|
-
#
|
14
|
-
# @param [String] code The locale code of the entry
|
15
|
-
#
|
16
|
-
# Example
|
17
|
-
# @entry = @stack.content_type('category').entry(entry_uid)
|
18
|
-
# @entry.locale('en-us')
|
19
|
-
#
|
20
|
-
# @return [Contentstack::Entry]
|
21
|
-
def locale(code)
|
22
|
-
@query[:locale] = code
|
23
|
-
self
|
24
|
-
end
|
25
|
-
|
26
|
-
# Specifies an array of 'only' keys in BASE object that would be 'included' in the response.
|
27
|
-
#
|
28
|
-
# @param [Array] fields Array of the 'only' reference keys to be included in response.
|
29
|
-
# @param [Array] fields_with_base Can be used to denote 'only' fields of the reference class
|
30
|
-
#
|
31
|
-
# Example
|
32
|
-
# # Include only title and description field in response
|
33
|
-
# @entry = @stack.content_type('category').entry(entry_uid)
|
34
|
-
# @entry.only(['title', 'description'])
|
35
|
-
#
|
36
|
-
# # Query product and include only the title and description from category reference
|
37
|
-
# @entry = @stack.content_type('product').entry(entry_uid)
|
38
|
-
# @entry.include_reference('category')
|
39
|
-
# .only('category', ['title', 'description'])
|
40
|
-
#
|
41
|
-
# @return [Contentstack::Entry]
|
42
|
-
def only(fields, fields_with_base=nil)
|
43
|
-
q = {}
|
44
|
-
if [Array, String].include?(fields_with_base.class)
|
45
|
-
fields_with_base = [fields_with_base] if fields_with_base.class == String
|
46
|
-
q[fields.to_sym] = fields_with_base
|
47
|
-
else
|
48
|
-
fields = [fields] if fields.class == String
|
49
|
-
q = {BASE: fields}
|
50
|
-
end
|
51
|
-
|
52
|
-
@query[:only] = q
|
53
|
-
self
|
54
|
-
end
|
55
|
-
|
56
|
-
# Specifies list of field uids that would be 'excluded' from the response.
|
57
|
-
#
|
58
|
-
# @param [Array] fields Array of field uid which get 'excluded' from the response.
|
59
|
-
# @param [Array] fields_with_base Can be used to denote 'except' fields of the reference class
|
60
|
-
#
|
61
|
-
# Example
|
62
|
-
# # Exclude 'description' field in response
|
63
|
-
# @entry = @stack.content_type('category').entry(entry_uid)
|
64
|
-
# @entry.except(['description'])
|
65
|
-
#
|
66
|
-
# # Query product and exclude the 'description' from category reference
|
67
|
-
# @entry = @stack.content_type('product').entry(entry_uid)
|
68
|
-
# @entry.include_reference('category')
|
69
|
-
# .except('category', ['description'])
|
70
|
-
#
|
71
|
-
# @return [Contentstack::Entry]
|
72
|
-
def except(fields, fields_with_base=nil)
|
73
|
-
q = {}
|
74
|
-
if [Array, String].include?(fields_with_base.class)
|
75
|
-
fields_with_base = [fields_with_base] if fields_with_base.class == String
|
76
|
-
q[fields.to_sym] = fields_with_base
|
77
|
-
else
|
78
|
-
fields = [fields] if fields.class == String
|
79
|
-
q = {BASE: fields}
|
80
|
-
end
|
81
|
-
|
82
|
-
@query[:except] = q
|
83
|
-
self
|
84
|
-
end
|
85
|
-
|
86
|
-
# Add a constraint that requires a particular reference key details.
|
87
|
-
#
|
88
|
-
# @param [String/Array] reference_field_uids Pass string or array of reference fields that must be included in the response
|
89
|
-
#
|
90
|
-
# Example
|
91
|
-
#
|
92
|
-
# # Include reference of 'category'
|
93
|
-
# @entry = @stack.content_type('product').entry(entry_uid)
|
94
|
-
# @entry.include_reference('category')
|
95
|
-
#
|
96
|
-
# # Include reference of 'category' and 'reviews'
|
97
|
-
# @entry = @stack.content_type('product').entry(entry_uid)
|
98
|
-
# @entry.include_reference(['category', 'reviews'])
|
99
|
-
#
|
100
|
-
# @return [Contentstack::Entry]
|
101
|
-
def include_reference(reference_field_uids)
|
102
|
-
self.include(reference_field_uids)
|
103
|
-
end
|
104
|
-
|
105
|
-
# Include schemas of all returned objects along with objects themselves.
|
106
|
-
#
|
107
|
-
# Example
|
108
|
-
#
|
109
|
-
# @entry = @stack.content_type('product').entry(entry_uid)
|
110
|
-
# @entry.include_schema
|
111
|
-
#
|
112
|
-
# @return [Contentstack::Entry]
|
113
|
-
def include_schema(flag=true)
|
114
|
-
@query[:include_schema] = flag
|
115
|
-
self
|
116
|
-
end
|
117
|
-
|
118
|
-
# Include object owner's profile in the objects data.
|
119
|
-
#
|
120
|
-
# Example
|
121
|
-
#
|
122
|
-
# @entry = @stack.content_type('product').entry(entry_uid)
|
123
|
-
# @entry.include_owner
|
124
|
-
#
|
125
|
-
# @return [Contentstack::Entry]
|
126
|
-
def include_owner(flag=true)
|
127
|
-
@query[:include_owner] = flag
|
128
|
-
self
|
129
|
-
end
|
130
|
-
|
131
|
-
# Include object's content_type in response
|
132
|
-
#
|
133
|
-
# Example
|
134
|
-
#
|
135
|
-
# @entry = @stack.content_type('product').entry(entry_uid)
|
136
|
-
# @entry.include_content_type
|
137
|
-
#
|
138
|
-
# @return [Contentstack::Entry]
|
139
|
-
def include_content_type(flag=true)
|
140
|
-
@query[:include_content_type] = flag
|
141
|
-
self
|
142
|
-
end
|
143
|
-
|
144
|
-
# Include the fallback locale publish content, if specified locale content is not publish.
|
145
|
-
#
|
146
|
-
# Example
|
147
|
-
#
|
148
|
-
# @entry = @stack.content_type('product').entry(entry_uid)
|
149
|
-
# @entry.include_fallback
|
150
|
-
#
|
151
|
-
# @return [Contentstack::Entry]
|
152
|
-
def include_fallback(flag=true)
|
153
|
-
@query[:include_fallback] = flag
|
154
|
-
self
|
155
|
-
end
|
156
|
-
|
157
|
-
# Include the branch for publish content.
|
158
|
-
#
|
159
|
-
# Example
|
160
|
-
#
|
161
|
-
# @entry = @stack.content_type('product').entry(entry_uid)
|
162
|
-
# @entry.include_branch
|
163
|
-
#
|
164
|
-
# @return [Contentstack::Entry]
|
165
|
-
def include_branch(flag=true)
|
166
|
-
@query[:include_branch] = flag
|
167
|
-
self
|
168
|
-
end
|
169
|
-
|
170
|
-
# Include Embedded Objects (Entries and Assets) along with entry/entries details.
|
171
|
-
#
|
172
|
-
# Example
|
173
|
-
#
|
174
|
-
# @entry = @stack.content_type('product').entry(entry_uid)
|
175
|
-
# @entry.include_embedded_items
|
176
|
-
#
|
177
|
-
# @return [Contentstack::Query]
|
178
|
-
def include_embedded_items()
|
179
|
-
@query[:include_embedded_items] = ['BASE']
|
180
|
-
self
|
181
|
-
end
|
182
|
-
|
183
|
-
#
|
184
|
-
# @return [Contentstack::Query]
|
185
|
-
def include(field_uids)
|
186
|
-
field_uids = [field_uids] if field_uids.class == String
|
187
|
-
@query[:include] ||= []
|
188
|
-
@query[:include] = @query[:include] | field_uids
|
189
|
-
self
|
190
|
-
end
|
191
|
-
|
192
|
-
# Execute entry
|
193
|
-
#
|
194
|
-
# Example
|
195
|
-
#
|
196
|
-
# @entry = @stack.content_type('product').entry(entry_uid)
|
197
|
-
# @entry.fetch
|
198
|
-
#
|
199
|
-
# @return [Contentstack::EntryCollection]
|
200
|
-
def fetch
|
201
|
-
entry = API.fetch_entry(@content_type, self.fields[:uid], @query)
|
202
|
-
setup(entry["entry"])
|
203
|
-
@schema = entry["schema"].symbolize_keys if entry["schema"]
|
204
|
-
@content_type = entry["content_type"].symbolize_keys if entry["content_type"]
|
205
|
-
self
|
206
|
-
end
|
207
|
-
|
208
|
-
def get(field_uid)
|
209
|
-
raise Contentstack::Error("Please send a valid Field UID") if field_uid.class != String
|
210
|
-
@fields[field_uid.to_sym]
|
211
|
-
end
|
212
|
-
|
213
|
-
private
|
214
|
-
def setup(attrs, content_type_uid=nil)
|
215
|
-
@fields = attrs.symbolize_keys
|
216
|
-
@content_type = content_type_uid if !content_type_uid.blank?
|
217
|
-
@owner = attrs[:_owner] if attrs[:_owner]
|
218
|
-
@uid = attrs[:uid]
|
219
|
-
@query = {}
|
220
|
-
end
|
221
|
-
end
|
1
|
+
require 'active_support/core_ext'
|
2
|
+
require 'util'
|
3
|
+
|
4
|
+
module Contentstack
|
5
|
+
class Entry
|
6
|
+
using Utility
|
7
|
+
attr_reader :fields, :content_type, :uid, :owner, :query, :schema, :content_type
|
8
|
+
def initialize(attrs, content_type_uid=nil)
|
9
|
+
setup(attrs, content_type_uid)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Get entries from the specified locale.
|
13
|
+
#
|
14
|
+
# @param [String] code The locale code of the entry
|
15
|
+
#
|
16
|
+
# Example
|
17
|
+
# @entry = @stack.content_type('category').entry(entry_uid)
|
18
|
+
# @entry.locale('en-us')
|
19
|
+
#
|
20
|
+
# @return [Contentstack::Entry]
|
21
|
+
def locale(code)
|
22
|
+
@query[:locale] = code
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
# Specifies an array of 'only' keys in BASE object that would be 'included' in the response.
|
27
|
+
#
|
28
|
+
# @param [Array] fields Array of the 'only' reference keys to be included in response.
|
29
|
+
# @param [Array] fields_with_base Can be used to denote 'only' fields of the reference class
|
30
|
+
#
|
31
|
+
# Example
|
32
|
+
# # Include only title and description field in response
|
33
|
+
# @entry = @stack.content_type('category').entry(entry_uid)
|
34
|
+
# @entry.only(['title', 'description'])
|
35
|
+
#
|
36
|
+
# # Query product and include only the title and description from category reference
|
37
|
+
# @entry = @stack.content_type('product').entry(entry_uid)
|
38
|
+
# @entry.include_reference('category')
|
39
|
+
# .only('category', ['title', 'description'])
|
40
|
+
#
|
41
|
+
# @return [Contentstack::Entry]
|
42
|
+
def only(fields, fields_with_base=nil)
|
43
|
+
q = {}
|
44
|
+
if [Array, String].include?(fields_with_base.class)
|
45
|
+
fields_with_base = [fields_with_base] if fields_with_base.class == String
|
46
|
+
q[fields.to_sym] = fields_with_base
|
47
|
+
else
|
48
|
+
fields = [fields] if fields.class == String
|
49
|
+
q = {BASE: fields}
|
50
|
+
end
|
51
|
+
|
52
|
+
@query[:only] = q
|
53
|
+
self
|
54
|
+
end
|
55
|
+
|
56
|
+
# Specifies list of field uids that would be 'excluded' from the response.
|
57
|
+
#
|
58
|
+
# @param [Array] fields Array of field uid which get 'excluded' from the response.
|
59
|
+
# @param [Array] fields_with_base Can be used to denote 'except' fields of the reference class
|
60
|
+
#
|
61
|
+
# Example
|
62
|
+
# # Exclude 'description' field in response
|
63
|
+
# @entry = @stack.content_type('category').entry(entry_uid)
|
64
|
+
# @entry.except(['description'])
|
65
|
+
#
|
66
|
+
# # Query product and exclude the 'description' from category reference
|
67
|
+
# @entry = @stack.content_type('product').entry(entry_uid)
|
68
|
+
# @entry.include_reference('category')
|
69
|
+
# .except('category', ['description'])
|
70
|
+
#
|
71
|
+
# @return [Contentstack::Entry]
|
72
|
+
def except(fields, fields_with_base=nil)
|
73
|
+
q = {}
|
74
|
+
if [Array, String].include?(fields_with_base.class)
|
75
|
+
fields_with_base = [fields_with_base] if fields_with_base.class == String
|
76
|
+
q[fields.to_sym] = fields_with_base
|
77
|
+
else
|
78
|
+
fields = [fields] if fields.class == String
|
79
|
+
q = {BASE: fields}
|
80
|
+
end
|
81
|
+
|
82
|
+
@query[:except] = q
|
83
|
+
self
|
84
|
+
end
|
85
|
+
|
86
|
+
# Add a constraint that requires a particular reference key details.
|
87
|
+
#
|
88
|
+
# @param [String/Array] reference_field_uids Pass string or array of reference fields that must be included in the response
|
89
|
+
#
|
90
|
+
# Example
|
91
|
+
#
|
92
|
+
# # Include reference of 'category'
|
93
|
+
# @entry = @stack.content_type('product').entry(entry_uid)
|
94
|
+
# @entry.include_reference('category')
|
95
|
+
#
|
96
|
+
# # Include reference of 'category' and 'reviews'
|
97
|
+
# @entry = @stack.content_type('product').entry(entry_uid)
|
98
|
+
# @entry.include_reference(['category', 'reviews'])
|
99
|
+
#
|
100
|
+
# @return [Contentstack::Entry]
|
101
|
+
def include_reference(reference_field_uids)
|
102
|
+
self.include(reference_field_uids)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Include schemas of all returned objects along with objects themselves.
|
106
|
+
#
|
107
|
+
# Example
|
108
|
+
#
|
109
|
+
# @entry = @stack.content_type('product').entry(entry_uid)
|
110
|
+
# @entry.include_schema
|
111
|
+
#
|
112
|
+
# @return [Contentstack::Entry]
|
113
|
+
def include_schema(flag=true)
|
114
|
+
@query[:include_schema] = flag
|
115
|
+
self
|
116
|
+
end
|
117
|
+
|
118
|
+
# Include object owner's profile in the objects data.
|
119
|
+
#
|
120
|
+
# Example
|
121
|
+
#
|
122
|
+
# @entry = @stack.content_type('product').entry(entry_uid)
|
123
|
+
# @entry.include_owner
|
124
|
+
#
|
125
|
+
# @return [Contentstack::Entry]
|
126
|
+
def include_owner(flag=true)
|
127
|
+
@query[:include_owner] = flag
|
128
|
+
self
|
129
|
+
end
|
130
|
+
|
131
|
+
# Include object's content_type in response
|
132
|
+
#
|
133
|
+
# Example
|
134
|
+
#
|
135
|
+
# @entry = @stack.content_type('product').entry(entry_uid)
|
136
|
+
# @entry.include_content_type
|
137
|
+
#
|
138
|
+
# @return [Contentstack::Entry]
|
139
|
+
def include_content_type(flag=true)
|
140
|
+
@query[:include_content_type] = flag
|
141
|
+
self
|
142
|
+
end
|
143
|
+
|
144
|
+
# Include the fallback locale publish content, if specified locale content is not publish.
|
145
|
+
#
|
146
|
+
# Example
|
147
|
+
#
|
148
|
+
# @entry = @stack.content_type('product').entry(entry_uid)
|
149
|
+
# @entry.include_fallback
|
150
|
+
#
|
151
|
+
# @return [Contentstack::Entry]
|
152
|
+
def include_fallback(flag=true)
|
153
|
+
@query[:include_fallback] = flag
|
154
|
+
self
|
155
|
+
end
|
156
|
+
|
157
|
+
# Include the branch for publish content.
|
158
|
+
#
|
159
|
+
# Example
|
160
|
+
#
|
161
|
+
# @entry = @stack.content_type('product').entry(entry_uid)
|
162
|
+
# @entry.include_branch
|
163
|
+
#
|
164
|
+
# @return [Contentstack::Entry]
|
165
|
+
def include_branch(flag=true)
|
166
|
+
@query[:include_branch] = flag
|
167
|
+
self
|
168
|
+
end
|
169
|
+
|
170
|
+
# Include Embedded Objects (Entries and Assets) along with entry/entries details.
|
171
|
+
#
|
172
|
+
# Example
|
173
|
+
#
|
174
|
+
# @entry = @stack.content_type('product').entry(entry_uid)
|
175
|
+
# @entry.include_embedded_items
|
176
|
+
#
|
177
|
+
# @return [Contentstack::Query]
|
178
|
+
def include_embedded_items()
|
179
|
+
@query[:include_embedded_items] = ['BASE']
|
180
|
+
self
|
181
|
+
end
|
182
|
+
|
183
|
+
#
|
184
|
+
# @return [Contentstack::Query]
|
185
|
+
def include(field_uids)
|
186
|
+
field_uids = [field_uids] if field_uids.class == String
|
187
|
+
@query[:include] ||= []
|
188
|
+
@query[:include] = @query[:include] | field_uids
|
189
|
+
self
|
190
|
+
end
|
191
|
+
|
192
|
+
# Execute entry
|
193
|
+
#
|
194
|
+
# Example
|
195
|
+
#
|
196
|
+
# @entry = @stack.content_type('product').entry(entry_uid)
|
197
|
+
# @entry.fetch
|
198
|
+
#
|
199
|
+
# @return [Contentstack::EntryCollection]
|
200
|
+
def fetch
|
201
|
+
entry = API.fetch_entry(@content_type, self.fields[:uid], @query)
|
202
|
+
setup(entry["entry"])
|
203
|
+
@schema = entry["schema"].symbolize_keys if entry["schema"]
|
204
|
+
@content_type = entry["content_type"].symbolize_keys if entry["content_type"]
|
205
|
+
self
|
206
|
+
end
|
207
|
+
|
208
|
+
def get(field_uid)
|
209
|
+
raise Contentstack::Error("Please send a valid Field UID") if field_uid.class != String
|
210
|
+
@fields[field_uid.to_sym]
|
211
|
+
end
|
212
|
+
|
213
|
+
private
|
214
|
+
def setup(attrs, content_type_uid=nil)
|
215
|
+
@fields = attrs.symbolize_keys
|
216
|
+
@content_type = content_type_uid if !content_type_uid.blank?
|
217
|
+
@owner = attrs[:_owner] if attrs[:_owner]
|
218
|
+
@uid = attrs[:uid]
|
219
|
+
@query = {}
|
220
|
+
end
|
221
|
+
end
|
222
222
|
end
|
@@ -1,45 +1,45 @@
|
|
1
|
-
require 'contentstack/entry'
|
2
|
-
require 'util'
|
3
|
-
|
4
|
-
module Contentstack
|
5
|
-
class EntryCollection
|
6
|
-
using Utility
|
7
|
-
attr_reader :entries, :count, :content_type, :schema
|
8
|
-
|
9
|
-
def initialize(json, content_type_uid=nil)
|
10
|
-
@count = json["count"] if json["count"]
|
11
|
-
@entries = json["entries"].collect{|entry| Entry.new(entry, content_type_uid) }
|
12
|
-
@schema = json["schema"].symbolize_keys if json["schema"]
|
13
|
-
@content_type = json["content_type"].symbolize_keys if json["content_type"]
|
14
|
-
self
|
15
|
-
end
|
16
|
-
|
17
|
-
def each &block
|
18
|
-
@entries.map{|e| block.call(e)}
|
19
|
-
end
|
20
|
-
|
21
|
-
def map &block
|
22
|
-
self.each(&block)
|
23
|
-
end
|
24
|
-
|
25
|
-
def collect &block
|
26
|
-
self.each(&block)
|
27
|
-
end
|
28
|
-
|
29
|
-
def length
|
30
|
-
@entries.length
|
31
|
-
end
|
32
|
-
|
33
|
-
def first
|
34
|
-
@entries.first
|
35
|
-
end
|
36
|
-
|
37
|
-
def last
|
38
|
-
@entries.last
|
39
|
-
end
|
40
|
-
|
41
|
-
def get(index)
|
42
|
-
@entries[index]
|
43
|
-
end
|
44
|
-
end
|
1
|
+
require 'contentstack/entry'
|
2
|
+
require 'util'
|
3
|
+
|
4
|
+
module Contentstack
|
5
|
+
class EntryCollection
|
6
|
+
using Utility
|
7
|
+
attr_reader :entries, :count, :content_type, :schema
|
8
|
+
|
9
|
+
def initialize(json, content_type_uid=nil)
|
10
|
+
@count = json["count"] if json["count"]
|
11
|
+
@entries = json["entries"].collect{|entry| Entry.new(entry, content_type_uid) }
|
12
|
+
@schema = json["schema"].symbolize_keys if json["schema"]
|
13
|
+
@content_type = json["content_type"].symbolize_keys if json["content_type"]
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def each &block
|
18
|
+
@entries.map{|e| block.call(e)}
|
19
|
+
end
|
20
|
+
|
21
|
+
def map &block
|
22
|
+
self.each(&block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def collect &block
|
26
|
+
self.each(&block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def length
|
30
|
+
@entries.length
|
31
|
+
end
|
32
|
+
|
33
|
+
def first
|
34
|
+
@entries.first
|
35
|
+
end
|
36
|
+
|
37
|
+
def last
|
38
|
+
@entries.last
|
39
|
+
end
|
40
|
+
|
41
|
+
def get(index)
|
42
|
+
@entries[index]
|
43
|
+
end
|
44
|
+
end
|
45
45
|
end
|
data/lib/contentstack/error.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
module Contentstack
|
2
|
-
class Error < StandardError
|
3
|
-
def initialize(msg="Something Went Wrong.")
|
4
|
-
super
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module Contentstack
|
2
|
+
class Error < StandardError
|
3
|
+
def initialize(msg="Something Went Wrong.")
|
4
|
+
super
|
5
|
+
end
|
6
|
+
end
|
7
7
|
end
|