infopark_cloud_connector 6.8.1.26.236500544 → 6.8.2.7.128454143

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,12 +29,11 @@ module RailsConnector
29
29
  end
30
30
  end
31
31
 
32
- # Overwrite this method in your project.
33
32
  # If +true+, allow access to ObjsController, else deny access.
34
- # Default: +false+
33
+ # See {RailsConnector::Configuration.editing_auth} for details.
35
34
  # @return [Bool]
36
35
  def allow_access?
37
- false
36
+ Configuration.editing_auth_callback.call(request.env)
38
37
  end
39
38
 
40
39
  end
@@ -5,7 +5,7 @@ require 'kvom'
5
5
  module RailsConnector
6
6
  # The CMS file class
7
7
  # @api public
8
- class Obj
8
+ class BasicObj
9
9
  extend ActiveModel::Naming
10
10
  include Kvom::ModelIdentity
11
11
 
@@ -27,7 +27,7 @@ module RailsConnector
27
27
  # May result in an instance of a subclass of Obj according to STI rules.
28
28
  def self.instantiate(obj_data)
29
29
  obj_class = obj_data.value_of("_obj_class")
30
- Obj.compute_type(obj_class).new(obj_data)
30
+ BasicObj.compute_type(obj_class).new(obj_data)
31
31
  end
32
32
 
33
33
  # @api public
@@ -48,7 +48,7 @@ module RailsConnector
48
48
  find_objs_by(:id, id_or_list).map(&:first)
49
49
  else
50
50
  obj = find_objs_by(:id, [id_or_list.to_s]).first.first
51
- obj or raise ResourceNotFound, "Could not find #{self} with id #{id_or_list}"
51
+ obj or raise ResourceNotFound, "Could not find Obj with id #{id_or_list}"
52
52
  end
53
53
  end
54
54
 
@@ -75,7 +75,7 @@ module RailsConnector
75
75
  # @return [ObjSearchEnumerator]
76
76
  # @api public
77
77
  def self.all
78
- if self.name == 'RailsConnector::Obj'
78
+ if superclass == RailsConnector::BasicObj
79
79
  ObjSearchEnumerator.new(nil)
80
80
  else
81
81
  find_all_by_obj_class(self.name)
@@ -135,14 +135,14 @@ module RailsConnector
135
135
  # @api public
136
136
  def self.find_by_permalink!(permalink)
137
137
  find_by_permalink(permalink) or
138
- raise ResourceNotFound, "Could not find #{self} with permalink '#{permalink}'"
138
+ raise ResourceNotFound, "Could not find Obj with permalink '#{permalink}'"
139
139
  end
140
140
 
141
141
  # accepts the name of an "obj_by" - view and a list of keys.
142
142
  # returns a list of lists of Objs: a list of Objs for each given keys.
143
143
  def self.find_objs_by(view, keys)
144
144
  CmsBackend.find_obj_data_by(Workspace.current.data, view, keys).map do |list|
145
- list.map { |obj_data| Obj.instantiate(obj_data) }
145
+ list.map { |obj_data| BasicObj.instantiate(obj_data) }
146
146
  end
147
147
  end
148
148
 
@@ -167,7 +167,7 @@ module RailsConnector
167
167
 
168
168
  def self.compute_type(type_name)
169
169
  @compute_type_cache ||= {}
170
- @compute_type_cache[type_name] ||= try_type { type_name.constantize } || self
170
+ @compute_type_cache[type_name] ||= try_type { type_name.constantize } || Obj
171
171
  end
172
172
 
173
173
  def self.reset_type_cache
@@ -178,7 +178,7 @@ module RailsConnector
178
178
  # returns +nil+ for the root Obj.
179
179
  # @api public
180
180
  def parent
181
- root? ? nil : Obj.find_by_path(parent_path)
181
+ root? ? nil : BasicObj.find_by_path(parent_path)
182
182
  end
183
183
 
184
184
  # Returns an Array of all the ancestor objects, starting at the root and ending at this object's parent.
@@ -190,14 +190,14 @@ module RailsConnector
190
190
  list << list.last + component
191
191
  end
192
192
  ancestor_paths[0] = "/"
193
- Obj.find_many_by_paths(ancestor_paths)
193
+ BasicObj.find_many_by_paths(ancestor_paths)
194
194
  end
195
195
 
196
196
  # return a list of all child Objs.
197
197
  # @return [Array<Obj>]
198
198
  # @api public
199
199
  def children
200
- Obj.find_objs_by(:ppath, [path]).first
200
+ self.class.find_objs_by(:ppath, [path]).first
201
201
  end
202
202
 
203
203
  ### ATTRIBUTES #################
@@ -205,7 +205,7 @@ module RailsConnector
205
205
  # returns the Obj's path as a String.
206
206
  # @api public
207
207
  def path
208
- read_attribute('_path') or raise "Obj without path"
208
+ read_attribute('_path') or raise 'Obj without path'
209
209
  end
210
210
 
211
211
  # returns the Obj's name, i.e. the last component of the path.
@@ -245,10 +245,11 @@ module RailsConnector
245
245
  # @return [Obj]
246
246
  # @api public
247
247
  def self.root
248
- Obj.find_by_path("/") or raise ResourceNotFound, "Obj.root not found: There is no Obj with path '/'."
248
+ BasicObj.find_by_path("/") or raise ResourceNotFound,
249
+ "Obj.root not found: There is no Obj with path '/'."
249
250
  end
250
251
 
251
- # Returns the homepage object. This can be overwritten in your application's +ObjExtensions+.
252
+ # Returns the homepage object. This can be overwritten in your application's +Obj+.
252
253
  # Use <tt>Obj#homepage?</tt> to check if an object is the homepage.
253
254
  # @return [Obj]
254
255
  # @api public
@@ -294,7 +295,7 @@ module RailsConnector
294
295
  # The default is {http://apidock.com/rails/ActiveSupport/Inflector/parameterize parameterize}
295
296
  # on +obj.title+.
296
297
  #
297
- # You can customize this part by overwriting +obj.slug+ in {ObjExtentions}.
298
+ # You can customize this part by overwriting +obj.slug+ in {Obj}.
298
299
  # @return [String]
299
300
  # @api public
300
301
  def slug
@@ -347,7 +348,7 @@ module RailsConnector
347
348
  # @api public
348
349
  def active?(time_when = nil)
349
350
  return false unless valid_from
350
- time_then = time_when || Obj.preview_time
351
+ time_then = time_when || BasicObj.preview_time
351
352
  valid_from <= time_then && (!valid_until || time_then <= valid_until)
352
353
  end
353
354
 
@@ -748,20 +749,14 @@ module RailsConnector
748
749
  private
749
750
 
750
751
  def try_type
751
- result = yield
752
- result if subclass_of_obj(result)
752
+ klass = yield
753
+ klass if klass.try(:descends_from_basic_obj?) # Descendants of BasicObj have this method
753
754
  rescue NameError
754
- nil
755
755
  end
756
756
 
757
- def subclass_of_obj(klass)
758
- if klass == Obj
759
- true
760
- else
761
- klass.superclass && subclass_of_obj(klass.superclass)
762
- end
757
+ def descends_from_basic_obj?
758
+ self != BasicObj
763
759
  end
764
-
765
760
  end
766
761
  end
767
762
 
@@ -36,7 +36,7 @@ module RailsConnector
36
36
  # Overwrite this method only if you know what you are doing.
37
37
  # @api public
38
38
  def self.find_named_link_obj
39
- Obj.find_by_path("/_named_links")
39
+ BasicObj.find_by_path("/_named_links")
40
40
  end
41
41
 
42
42
  def self.cache_expiry_time=(value)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_cloud_connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.8.1.26.236500544
4
+ version: 6.8.2.7.128454143
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-25 00:00:00.000000000 Z
12
+ date: 2013-01-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - '='
52
52
  - !ruby/object:Gem::Version
53
- version: 6.8.1.26.236500544
53
+ version: 6.8.2.7.128454143
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 6.8.1.26.236500544
61
+ version: 6.8.2.7.128454143
62
62
  description: The Cloud Connector for Infopark CMS Fiona enables you to develop modern,
63
63
  dynamic Web 2.0 applications using Ruby on Rails and at the same time display CMS
64
64
  managed content.
@@ -79,6 +79,7 @@ files:
79
79
  - lib/infopark_cloud_connector.rb
80
80
  - lib/rails_connector/access_denied.rb
81
81
  - lib/rails_connector/backend_not_available.rb
82
+ - lib/rails_connector/basic_obj.rb
82
83
  - lib/rails_connector/blob.rb
83
84
  - lib/rails_connector/cache.rb
84
85
  - lib/rails_connector/cache_middleware.rb
@@ -109,7 +110,6 @@ files:
109
110
  - lib/rails_connector/migrations/migrator.rb
110
111
  - lib/rails_connector/migrations/workspace_lock.rb
111
112
  - lib/rails_connector/named_link.rb
112
- - lib/rails_connector/obj.rb
113
113
  - lib/rails_connector/obj_data.rb
114
114
  - lib/rails_connector/obj_data_from_database.rb
115
115
  - lib/rails_connector/obj_data_from_hash.rb
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  segments:
144
144
  - 0
145
- hash: 620009807
145
+ hash: 903498323
146
146
  required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  none: false
148
148
  requirements: