ramen-rails 0.0.1 → 0.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 111502efcd48f7a5aed23061c7660baf7d0db589
4
- data.tar.gz: b52797f58a2979fd1c1aed4b9d1961f3c05f0895
3
+ metadata.gz: a15c33ea6b27c1c50f0fd07447be2ef4292e77f6
4
+ data.tar.gz: e285639be89f2f6c5571a9671f662f64aeeae013
5
5
  SHA512:
6
- metadata.gz: 7ae146cee640ef1adc7923f7baf4dae76081fec24fa9e47348154a4270961f20a3f1257faf54f82e26e5dbd7441aba62b35e9cfafc1efbe85ded45211247b091
7
- data.tar.gz: 40a10679f67dc5916e7f3fd9a27c593e215897d2bdc4fc3a41ba88afaf45c6e90d54f8cfb0eb5b27779600025fe4e79677a6e64b62f5839aa531af43886e3ab4
6
+ metadata.gz: 284b8b82a0cabbeacc989c8accfd407cb42e4b01cbe45923bda932cf757f72463f56635b103edf3873a5cf0c5ba4a5aa9b8db1f7a2cfd77f1215b5f0f36196a3
7
+ data.tar.gz: 1e2e1d87850827365dcf385fbcf0d281cbc85f2c30b438efe4eab258e6734be743d61de152f28ba0dd4e3d012e48ea716582dc01e72ac1aa8824ca33df5ad9e1
@@ -45,13 +45,4 @@ RamenRails.config do |config|
45
45
  #
46
46
  # config.current_company = Proc.new { current_company }
47
47
 
48
-
49
- ## How we access the current company "value". This is
50
- ## a Float. It can represent whatever you want.
51
- ##
52
- ## If config.current_user is empty, this will be ignored
53
- #
54
- # config.current_company_value = Proc.new { current_company_value }
55
-
56
-
57
48
  end
@@ -55,6 +55,11 @@ module RamenRails
55
55
  def ramen_user_labels
56
56
  return nil unless ramen_user_object
57
57
  instance_eval(&RamenRails.config.current_user_labels) if RamenRails.config.current_user_labels.present?
58
+ rescue NameError => e
59
+ Rails.logger.debug "Swallowing NameError. We're probably in an Engine or some other context like Devise."
60
+ Rails.logger.debug e
61
+
62
+ nil
58
63
  end
59
64
 
60
65
  def ramen_user_object
@@ -74,6 +79,11 @@ module RamenRails
74
79
  def ramen_user_value
75
80
  return nil unless ramen_user_object
76
81
  instance_eval(&RamenRails.config.current_user_value) if RamenRails.config.current_user_value.present?
82
+ rescue NameError => e
83
+ Rails.logger.debug "Swallowing NameError. We're probably in an Engine or some other context like Devise."
84
+ Rails.logger.debug e
85
+
86
+ nil
77
87
  end
78
88
 
79
89
  def ramen_org_id
@@ -94,7 +104,24 @@ module RamenRails
94
104
 
95
105
  def ramen_company
96
106
  return nil unless ramen_user_object
97
- instance_eval(&RamenRails.config.current_company) if RamenRails.config.current_company.present?
107
+
108
+ begin
109
+ company = instance_eval(&RamenRails.config.current_company) if RamenRails.config.current_company.present?
110
+ rescue NameError => e
111
+ Rails.logger.debug "Swallowing NameError. We're probably in an Engine or some other context like Devise."
112
+ Rails.logger.debug e
113
+
114
+ company = nil
115
+ end
116
+
117
+ return nil unless company
118
+
119
+ obj = {}
120
+ [:url, :id, :value, :name].each do |attr|
121
+ obj[attr] = user.send(attr) if user.respond_to?(attr) && user.send(attr).present?
122
+ end
123
+
124
+ obj
98
125
  end
99
126
 
100
127
 
@@ -113,7 +140,7 @@ module RamenRails
113
140
 
114
141
  obj[:user][:value] = ramen_user_value if ramen_user_value.present?
115
142
  obj[:user][:labels] = ramen_user_labels unless ramen_user_labels.nil?
116
-
143
+
117
144
  obj[:company] = ramen_company if ramen_company.present?
118
145
 
119
146
  super(obj, organization_secret: ramen_org_secret)
@@ -1,3 +1,3 @@
1
1
  module RamenRails
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ramen-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Angilly