intercom-rails 1.1.1 → 2.0.0
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/README.md +1 -1
- data/lib/intercom-rails/proxy/company.rb +1 -1
- data/lib/intercom-rails/proxy/user.rb +2 -5
- data/lib/intercom-rails/proxy.rb +7 -0
- data/lib/intercom-rails/version.rb +1 -1
- data/lib/rails/generators/intercom/config/config_generator.rb +2 -2
- data/lib/rails/generators/intercom/config/intercom.rb.erb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2e7d544e693716ec8e6927a28aa46d01d2c360544bfb0c9816193013e1d9686c
|
|
4
|
+
data.tar.gz: 732324518526f63c2202be3521a890f77d90d26953e103d0fc47ebdafd27f945
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b3b36ca475257f4c2ebdd89f93a517124e686ffc5b51f8c081dc96cabc4e47cf19b23ab0f34eb28f002dd116f186704701e0fd6fcf514bc09a207aa2d35f943
|
|
7
|
+
data.tar.gz: fdaafd9ba64ea6cdf9c9a7b681834b1cb1cd5b7cba4d1402b4a9c8d944ff4b792595482957bd7c106986e4add9cd1ec7fba670643de0518e85b2b290fae0bf2e
|
data/README.md
CHANGED
|
@@ -47,7 +47,7 @@ If things are not working make sure that:
|
|
|
47
47
|
|
|
48
48
|
* You've generated a config file with your `app_id` as detailed above.
|
|
49
49
|
* Your user object responds to an `id` or `email` method.
|
|
50
|
-
* Your current user is accessible in your controllers as `current_user
|
|
50
|
+
* Your current user is accessible in your controllers as `current_user`. If it is not, set it in `config/initializers/intercom.rb`:
|
|
51
51
|
```ruby
|
|
52
52
|
config.user.current = Proc.new { current_user_object }
|
|
53
53
|
```
|
|
@@ -24,7 +24,7 @@ module IntercomRails
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def valid?
|
|
27
|
-
return false if company.blank? ||
|
|
27
|
+
return false if company.blank? || unsaved?
|
|
28
28
|
return false if config.company.exclude_if.present? && config.company.exclude_if.call(company)
|
|
29
29
|
company.present? && identity_present?
|
|
30
30
|
end
|
|
@@ -9,10 +9,7 @@ module IntercomRails
|
|
|
9
9
|
proxy_delegator :name
|
|
10
10
|
proxy_delegator :created_at
|
|
11
11
|
|
|
12
|
-
PREDEFINED_POTENTIAL_USER_OBJECTS = [
|
|
13
|
-
Proc.new { current_user },
|
|
14
|
-
Proc.new { @user }
|
|
15
|
-
]
|
|
12
|
+
PREDEFINED_POTENTIAL_USER_OBJECTS = [Proc.new { current_user }]
|
|
16
13
|
|
|
17
14
|
def self.potential_user_objects
|
|
18
15
|
if config.current.present?
|
|
@@ -46,7 +43,7 @@ module IntercomRails
|
|
|
46
43
|
end
|
|
47
44
|
|
|
48
45
|
def valid?
|
|
49
|
-
return false if user.blank? ||
|
|
46
|
+
return false if user.blank? || unsaved?
|
|
50
47
|
return false if excluded?
|
|
51
48
|
identity_present?
|
|
52
49
|
end
|
data/lib/intercom-rails/proxy.rb
CHANGED
|
@@ -71,6 +71,13 @@ module IntercomRails
|
|
|
71
71
|
config.send(variable_name).present?
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
+
def unsaved?
|
|
75
|
+
return proxied_object.new_record? if proxied_object.respond_to?(:new_record?)
|
|
76
|
+
return !proxied_object.persisted? if proxied_object.respond_to?(:persisted?)
|
|
77
|
+
return proxied_object.new? if proxied_object.respond_to?(:new?)
|
|
78
|
+
false
|
|
79
|
+
end
|
|
80
|
+
|
|
74
81
|
def identity_present?
|
|
75
82
|
self.class.identity_attributes.any? { |attribute_name| (proxied_object.is_a?(Hash) && proxied_object[attribute_name].present?) || (proxied_object.respond_to?(attribute_name) && proxied_object.send(attribute_name).present?) }
|
|
76
83
|
end
|
|
@@ -20,9 +20,9 @@ module Intercom
|
|
|
20
20
|
introduction = <<-desc
|
|
21
21
|
Intercom will automatically insert its javascript before the closing '</body>'
|
|
22
22
|
tag on every page where it can find a logged-in user. Intercom by default
|
|
23
|
-
looks for logged-in users, in the controller, via 'current_user'
|
|
23
|
+
looks for logged-in users, in the controller, via 'current_user'.
|
|
24
24
|
|
|
25
|
-
Is the logged-in user accessible via
|
|
25
|
+
Is the logged-in user accessible via 'current_user'? [Yn]
|
|
26
26
|
desc
|
|
27
27
|
|
|
28
28
|
print "#{introduction.strip} "
|
|
@@ -27,7 +27,7 @@ IntercomRails.config do |config|
|
|
|
27
27
|
|
|
28
28
|
# == Current user method/variable
|
|
29
29
|
# The method/variable that contains the logged in user in your controllers.
|
|
30
|
-
# If it is `current_user
|
|
30
|
+
# If it is `current_user`, then you can ignore this
|
|
31
31
|
#
|
|
32
32
|
<%- if @current_user -%>
|
|
33
33
|
config.user.current = Proc.new { <%= @current_user %> }
|
metadata
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: intercom-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben McRedmond
|
|
8
8
|
- Ciaran Lee
|
|
9
9
|
- Darragh Curran
|
|
10
|
-
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: activesupport
|
|
@@ -187,7 +186,6 @@ homepage: http://www.intercom.io
|
|
|
187
186
|
licenses:
|
|
188
187
|
- MIT
|
|
189
188
|
metadata: {}
|
|
190
|
-
post_install_message:
|
|
191
189
|
rdoc_options: []
|
|
192
190
|
require_paths:
|
|
193
191
|
- lib
|
|
@@ -202,8 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
202
200
|
- !ruby/object:Gem::Version
|
|
203
201
|
version: '0'
|
|
204
202
|
requirements: []
|
|
205
|
-
rubygems_version:
|
|
206
|
-
signing_key:
|
|
203
|
+
rubygems_version: 4.0.11
|
|
207
204
|
specification_version: 4
|
|
208
205
|
summary: Rails helper for emitting javascript script tags for Intercom
|
|
209
206
|
test_files: []
|