duck_map 0.9.0 → 0.9.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edb5f6641ee44fc53ee42c4326333a03bf92f58a
4
- data.tar.gz: c689a439a43cf410584ea6f829681ab44f18dd7a
3
+ metadata.gz: 86ec3b2f41916cd82223eef468e8f6427c6f58fc
4
+ data.tar.gz: f5ca2a9974f3d7bfd16d3589c00e4956712b0b06
5
5
  SHA512:
6
- metadata.gz: dcf98311dc089a814d5a23613efbbef6176d6e81dc02653b8f884905fa4b67ab6a60f92af28f77e3a4eeb583ebdd4e0c37552017ac7f785e8c8a469760d699f7
7
- data.tar.gz: 1cb7c3261490d9f15bf0308433d73c80b7d48cbd17bffeae9d4fcea399a45c0fe8b09d7be5fc6350d7abf1caa7169273308edbc6c81dccac1b7ccf4cf2c2691b
6
+ metadata.gz: d248d028bfc527ecc8a7da12deae494b05de4fe80bd5a27854aa1e5e4f9fa431133c79995563dee93380b7f312ab6bb5cd4ca661f7ff82f36069a2b2c3e95bc6
7
+ data.tar.gz: 841e71bb490bf9b476e9ba04ad71be66a6dce110e3ed43688dfadb0c87d372df05857f470a2ab1b86a0df90c039e0805d80c45e967bd6a083230d9214be42695
@@ -128,8 +128,11 @@ module DuckMap
128
128
  def find_first_model_object
129
129
  model_object = self.find_model_object
130
130
 
131
- if model_object.kind_of?(Array) &&
132
- (model_object.first.kind_of?(ActiveRecord::Base) || model_object.first.kind_of?(Mongoid::Document))
131
+ #if model_object.kind_of?(Array) &&
132
+ #(model_object.first.kind_of?(ActiveRecord::Base) || model_object.first.kind_of?(Mongoid::Document))
133
+ #model_object = model_object.first
134
+ #end
135
+ if model_object.kind_of?(Array) && ::DuckMap::Model::Supported.is_supported?(model_object.first)
133
136
  model_object = model_object.first
134
137
  end
135
138
 
@@ -154,10 +157,10 @@ module DuckMap
154
157
  list.each do |obj_sym|
155
158
  obj = self.instance_variable_get(obj_sym)
156
159
  if obj
157
- if obj.kind_of?(ActiveRecord::Base) || obj.kind_of?(Mongoid::Document)
160
+ if ::DuckMap::Model::Supported.is_supported?(obj)
158
161
  model_object = obj
159
162
  break
160
- elsif obj.kind_of?(Array) &&
163
+ elsif obj.kind_of?(Array) && ::DuckMap::Model::Supported.is_supported?(obj.first)
161
164
  (obj.first.kind_of?(ActiveRecord::Base) || obj.first.kind_of?(Mongoid::Document)) &&
162
165
  candidate.blank?
163
166
  candidate = obj
@@ -61,10 +61,6 @@ module DuckMap
61
61
  ActiveRecord::Base.send :include, Attributes
62
62
  ActiveRecord::Base.send :include, SitemapObject
63
63
 
64
- Mongoid::Document.send :include, InheritableClassAttributes
65
- Mongoid::Document.send :include, Attributes
66
- Mongoid::Document.send :include, SitemapObject
67
-
68
64
  end
69
65
 
70
66
  ActiveSupport.on_load(:before_initialize) do
@@ -101,7 +101,7 @@ module DuckMap
101
101
 
102
102
  # data_rows may have changed from an Array to a model object.
103
103
  # Make data_rows an Array if it has been switched to an model object.
104
- if data_rows.kind_of?(ActiveRecord::Base) || data_rows.kind_of?(Mongoid::Document)
104
+ if ::DuckMap::Model::Supported.is_supported?(data_rows)
105
105
  data_rows = [data_rows]
106
106
  end
107
107
 
@@ -128,7 +128,7 @@ module DuckMap
128
128
 
129
129
  # data_rows may have changed from an Array to a model object.
130
130
  # Make data_rows an Array if it has been switched to an model object.
131
- if data_rows.kind_of?(ActiveRecord::Base) || data_rows.kind_of?(Mongoid::Document)
131
+ if ::DuckMap::Model::Supported.is_supported?(data_rows)
132
132
  data_rows = [data_rows]
133
133
  end
134
134
 
@@ -8,6 +8,8 @@ module DuckMap
8
8
  module Model
9
9
  extend ActiveSupport::Concern
10
10
 
11
+ autoload :Supported, 'duck_map/model'
12
+
11
13
  ##################################################################################
12
14
  # Array containing all of the Hash objects that represent the contents of a single sitemap.
13
15
  # Originally, this method was part of {DuckMap::ControllerHelpers}, however, it was separated
@@ -21,6 +23,35 @@ module DuckMap
21
23
  @sitemap_model = value
22
24
  end
23
25
 
26
+ ##################################################################################
27
+ class Supported
28
+
29
+ ##################################################################################
30
+ def self.models
31
+ unless defined?(@@models)
32
+ @@models = [ActiveRecord::Base, ActiveRecord::Relation]
33
+ end
34
+ return @@models
35
+ end
36
+
37
+ ##################################################################################
38
+ def self.is_supported?(obj)
39
+ value = false
40
+
41
+ unless obj.blank?
42
+ self.models.each do |model|
43
+ if obj.kind_of?(model)
44
+ value = true
45
+ break
46
+ end
47
+ end
48
+ end
49
+
50
+ return value
51
+ end
52
+
53
+ end
54
+
24
55
  end
25
56
 
26
57
  end
@@ -0,0 +1,18 @@
1
+ module DuckMap
2
+ extend ActiveSupport::Autoload
3
+
4
+ class MongoidEngine < Rails::Engine
5
+
6
+ ActiveSupport.on_load(:active_record) do
7
+
8
+ Mongoid::Document.send :include, InheritableClassAttributes
9
+ Mongoid::Document.send :include, Attributes
10
+ Mongoid::Document.send :include, SitemapObject
11
+
12
+ Model::Supported.models.push(Mongoid::Document)
13
+
14
+ end
15
+
16
+ end
17
+
18
+ end
@@ -1,3 +1,3 @@
1
1
  module DuckMap
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
@@ -0,0 +1,5 @@
1
+ require "duck_map/engine"
2
+ require "duck_map/mongoid_engine"
3
+
4
+ module DuckMap
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duck_map
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Duckett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-03 00:00:00.000000000 Z
11
+ date: 2014-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -92,7 +92,9 @@ files:
92
92
  - lib/duck_map/last_mod.rb
93
93
  - lib/duck_map/class_helpers.rb
94
94
  - lib/duck_map/route_filter.rb
95
+ - lib/duck_map/mongoid_engine.rb
95
96
  - lib/duck_map.rb
97
+ - lib/duck_map_mongoid.rb
96
98
  - app/views/sitemap/default_template.xml.erb
97
99
  - app/controllers/sitemap_base_controller.rb
98
100
  - app/controllers/sitemap_controller.rb