active_force 0.7.0 → 0.7.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: f65b3ee4d09a2cc85b6ff35e563104b90e35ef2e
4
- data.tar.gz: 865295aff9ee4dfc2962fa13225d41041f3100d1
3
+ metadata.gz: 856379b1407c72d56da2e86be62b2a54af211d85
4
+ data.tar.gz: f35e9f84f5278754333157b749df193ce9f60034
5
5
  SHA512:
6
- metadata.gz: 54eac72eb1033454434c97b997810587004df5655134574a445f8826318c69eda74783f2a902bd75cffe4addd88a41b49b93451029284d2002ca4c2928c3c988
7
- data.tar.gz: 509928a1158a20cb8122efa37d98e893bf762ad1b9cf7329f35cf68ffed269fcd738a4613357bf4ec3830e86cffa6002b9d153baf6689356f555f5836f9b0248
6
+ metadata.gz: 15db0f8a8df68c7db8cf3eb8e2ebf5304748807823957b61e2348a90459615a7140b7fdf20753ad832ce7c2a24fb9a76e3df612bbde1b44e780d220f8f0f451c
7
+ data.tar.gz: e571dcf6b46d18b2d7fe1927600b7aafccbb5d12506ddaba558dbe3f18373967e5514818542b1d17d7cab455bfc9fea4f474ece36aed8fe768359e52cd14b65a
@@ -1,6 +1,13 @@
1
1
  # Changelog
2
2
 
3
3
  ## Not released
4
+
5
+ ## 0.7.1
6
+
7
+ * Allow sfdc_client to be set. ([#92][])
8
+
9
+ ## 0.7.0
10
+
4
11
  * Rails4-style conditional has_many associations ([Dan Olson][])
5
12
  * Add `#includes` query method to eager load has_many association. ([Dan Olson][])
6
13
  * Add `#includes` query method to eager load belongs_to association. ([#65][])
@@ -84,6 +91,7 @@
84
91
  [#30]: https://github.com/ionia-corporation/active_force/issues/30
85
92
  [#33]: https://github.com/ionia-corporation/active_force/issues/33
86
93
  [#65]: https://github.com/ionia-corporation/active_force/issues/65
94
+ [#92]: https://github.com/ionia-corporation/active_force/issues/92
87
95
  [Pablo Oldani]: https://github.com/olvap
88
96
  [Armando Andini]: https://github.com/antico5
89
97
  [José Piccioni]: https://github.com/lmhsjackson
data/README.md CHANGED
@@ -38,6 +38,19 @@ environment variables to set up credentials.
38
38
 
39
39
  You might be interested in [dotenv-rails][3] to set up those in development.
40
40
 
41
+ Also, you may specify which client to use as a configuration option, which is useful
42
+ when having to reauthenticate utilizing oauth.
43
+
44
+ ```ruby
45
+ ActiveForce.sfdc_client = Restforce.new()
46
+ oauth_token: current_user.oauth_token,
47
+ refresh_token: current_user.refresh_token,
48
+ instance_url: current_user.instance_url,
49
+ client_id: SALESFORCE_CLIENT_ID,
50
+ client_secret: SALESFORCE_CLIENT_SECRET
51
+ )
52
+ ```
53
+
41
54
  ## Usage
42
55
 
43
56
  ```ruby
@@ -47,6 +60,14 @@ class Medication < ActiveForce::SObject
47
60
 
48
61
  field :max_dossage # defaults to "Max_Dossage__c"
49
62
  field :updated_from
63
+
64
+ ##
65
+ # You can cast field value using `as`
66
+ # field :address_primary_active, from: 's360a__AddressPrimaryActive__c', as: :boolean
67
+ #
68
+ # Available options are :boolean, :int, :double, :percent, :date, :datetime, :string, :base64,
69
+ # :byte, :ID, :reference, :currency, :textarea, :phone, :url, :email, :combobox, :picklist,
70
+ # :multipicklist, :anyType, :location
50
71
 
51
72
  ##
52
73
  # Table name is inferred from class name.
@@ -97,7 +118,7 @@ class Account < ActiveForce::SObject
97
118
 
98
119
  has_many :today_log_entries,
99
120
  model: DailyLogEntry,
100
- scoped_as: ->{ where(date: Time.now.in_time_zone.strftime("%Y-%m-%d") }
121
+ scoped_as: ->{ where(date: Time.now.in_time_zone.strftime("%Y-%m-%d")) }
101
122
 
102
123
  has_many :labs,
103
124
  scoped_as: ->{ where("Category__c = 'EMR' AND Date__c <> NULL").order('Date__c DESC') }
@@ -3,4 +3,11 @@ require 'active_force/sobject'
3
3
  require 'active_force/query'
4
4
 
5
5
  module ActiveForce
6
+
7
+ class << self
8
+ attr_accessor :sfdc_client
9
+ end
10
+
11
+ self.sfdc_client = Restforce.new
12
+
6
13
  end
@@ -42,7 +42,7 @@ module ActiveForce
42
42
 
43
43
  def infer_foreign_key_from_model(model)
44
44
  name = model.custom_table? ? model.name : model.table_name
45
- "#{name.downcase}_id".to_sym
45
+ name.foreign_key.to_sym
46
46
  end
47
47
  end
48
48
 
@@ -199,7 +199,7 @@ module ActiveForce
199
199
  end
200
200
 
201
201
  def self.sfdc_client
202
- @client ||= Restforce.new
202
+ ActiveForce.sfdc_client
203
203
  end
204
204
 
205
205
  def sfdc_client
@@ -1,3 +1,3 @@
1
1
  module ActiveForce
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
@@ -14,7 +14,7 @@ describe ActiveForce::SObject do
14
14
  end
15
15
 
16
16
  before do
17
- allow(ActiveForce::SObject).to receive(:sfdc_client).and_return client
17
+ ActiveForce.sfdc_client = client
18
18
  end
19
19
 
20
20
  describe "has_many_query" do
@@ -4,7 +4,7 @@ describe ActiveForce::SObject do
4
4
  let(:client) { double 'Client', create!: 'id' }
5
5
 
6
6
  before do
7
- allow(ActiveForce::SObject).to receive(:sfdc_client).and_return client
7
+ ActiveForce.sfdc_client = client
8
8
  end
9
9
 
10
10
  describe "save" do
@@ -5,7 +5,7 @@ module ActiveForce
5
5
  let(:client){ double "client" }
6
6
 
7
7
  before do
8
- allow(ActiveForce::SObject).to receive(:sfdc_client).and_return client
8
+ ActiveForce.sfdc_client = client
9
9
  end
10
10
 
11
11
  describe '.includes' do
@@ -5,7 +5,7 @@ describe ActiveForce::SObject do
5
5
  let(:client) { double 'Client' }
6
6
 
7
7
  before do
8
- allow(ActiveForce::SObject).to receive(:sfdc_client).and_return client
8
+ ActiveForce.sfdc_client = client
9
9
  end
10
10
 
11
11
  describe ".new" do
@@ -264,7 +264,7 @@ describe ActiveForce::SObject do
264
264
  let(:territory){ Territory.new(id: '1', quota_id: '1') }
265
265
 
266
266
  before do
267
- allow(ActiveForce::SObject).to receive(:sfdc_client).and_return client
267
+ ActiveForce.sfdc_client = client
268
268
  end
269
269
 
270
270
  it 'clears cached associations' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_force
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Espinaco
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-10-10 00:00:00.000000000 Z
14
+ date: 2014-10-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: active_attr
@@ -192,3 +192,4 @@ test_files:
192
192
  - spec/support/restforce_factories.rb
193
193
  - spec/support/sobjects.rb
194
194
  - spec/support/whizbang.rb
195
+ has_rdoc: