gmaps4rails 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,13 @@
1
1
  <% #thanks to enable_css, user can avoid this css to be loaded
2
- if enable_css == true and options[:scripts].nil? %>
3
- <% if Rails::VERSION::MAJOR >= 3 and Rails::VERSION::MINOR < 1 %>
2
+ if enable_css == true && options[:scripts].nil? %>
3
+ <% if Rails::VERSION::MAJOR >= 3 && Rails::VERSION::MINOR < 1 %>
4
4
  <% content_for :head do %>
5
5
  <%= stylesheet_link_tag 'gmaps4rails' %>
6
6
  <% end %>
7
7
  <% end %>
8
8
  <% end %>
9
9
  <% content_for :scripts do %>
10
- <% if enable_js == true and options[:scripts].try(:to_sym) != :none %>
10
+ <% if enable_js == true && options[:scripts].try(:to_sym) != :none %>
11
11
  <% case options[:map_options].try(:[], :provider) %>
12
12
  <% when "openlayers" %>
13
13
  <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
@@ -22,7 +22,7 @@ if enable_css == true and options[:scripts].nil? %>
22
22
  <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/src/richmarker-compiled.js"></script>
23
23
  <% end %>
24
24
 
25
- <% if Rails::VERSION::MAJOR >= 3 and Rails::VERSION::MINOR < 1 %>
25
+ <% if Rails::VERSION::MAJOR >= 3 && Rails::VERSION::MINOR < 1 %>
26
26
  <% unless options[:scripts].try(:to_sym) == :api %>
27
27
  <%= javascript_include_tag 'gmaps4rails/gmaps4rails.base.js' %>
28
28
  <% end %>
@@ -18,9 +18,10 @@ if defined?(Rails) && Rails::VERSION::MAJOR == 3
18
18
  end
19
19
 
20
20
  initializer "include acts_as_gmappable within ActiveRecord" do
21
- if defined?(::ActiveRecord::Base)
22
- ActiveRecord::Base.send(:include, Gmaps4rails::ActsAsGmappable::InstanceMethods)
23
- ActiveRecord::Base.send(:extend, Gmaps4rails::ActsAsGmappable::ClassMethods)
21
+ if defined? ::ActiveRecord
22
+ ActiveRecord::Base.send :include, Gmaps4rails::ActsAsGmappable
23
+ elsif defined? ::Mongoid
24
+ Mongoid::Document.send :include, Gmaps4rails::ActsAsGmappable
24
25
  end
25
26
  end
26
27
 
@@ -1,6 +1,11 @@
1
1
  module Gmaps4rails
2
2
  module ActsAsGmappable
3
-
3
+
4
+ def self.included base
5
+ base.send :include, InstanceMethods
6
+ base.send :extend, ClassMethods
7
+ end
8
+
4
9
  module InstanceMethods
5
10
 
6
11
  # This is a before_filter to trigger the geocoding and save its results
@@ -5,7 +5,8 @@ class Array
5
5
  output = "["
6
6
  json_array = []
7
7
  each do |object|
8
- json_array << Gmaps4rails.create_json(object, &block).to_s
8
+ json = Gmaps4rails.create_json(object, &block)
9
+ json_array << json.to_s unless json.nil?
9
10
  end
10
11
  output << json_array * (",")
11
12
  output << "]"
@@ -8,6 +8,8 @@ module Gmaps4rails
8
8
  handle_block(&block) if block_given?
9
9
  handle_model_methods
10
10
  return_json
11
+ else
12
+ nil
11
13
  end
12
14
  end
13
15
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmaps4rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 0
10
- version: 1.4.0
9
+ - 1
10
+ version: 1.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Benjamin Roth