signet-rails 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -77,7 +77,7 @@ module Signet
77
77
  # In this flow we might not yet have established a session... need to handle two
78
78
  # flows, one for login, one not
79
79
  # when on a login auth_callback, how do we get the persistence object from the JWT?
80
- combined_options[:extract_by_oauth_id] ||= lambda do |id, client|
80
+ combined_options[:extract_by_oauth_id] ||= lambda do |env, client, id|
81
81
  oac = nil
82
82
  begin
83
83
  u = nil
@@ -105,9 +105,12 @@ module Signet
105
105
  end
106
106
 
107
107
  combined_options[:persistence_wrapper] ||= :active_record
108
+
109
+ # define a lambda that returns a lambda that wraps our OAC lambda return object
110
+ # in a persistance object
108
111
  persistence_wrapper = lambda do |meth|
109
- lambda do |context, client|
110
- y = meth.call context, client
112
+ lambda do |env, client, *args|
113
+ y = meth.call env, client, *args
111
114
  klass_str = combined_options[:persistence_wrapper].to_s
112
115
  require "signet/rails/wrappers/#{klass_str}"
113
116
  w = "Signet::Rails::Wrappers::#{klass_str.camelize}".constantize.new y, client
@@ -50,7 +50,7 @@ module Signet
50
50
  client.fetch_access_token!
51
51
 
52
52
  if options[:handle_auth_callback]
53
- obj = options[:extract_by_oauth_id].call client.decoded_id_token['sub'], client
53
+ obj = options[:extract_by_oauth_id].call env, client, client.decoded_id_token['sub']
54
54
  persist_token_state obj, client
55
55
  obj.persist
56
56
  env["signet.#{options[:name]}.persistence_obj"] = obj.obj
@@ -71,12 +71,20 @@ module Signet
71
71
  store_hash = wrapper.obj.method("#{options[:storage_attr]}=").call({})
72
72
  end
73
73
 
74
+ # not nice... the wrapper.obj.changed? will only be triggered if we clone the hash
75
+ # Is this a bug? https://github.com/rails/rails/issues/11968
76
+ # TODO: check if there is a better solution
77
+ store_hash = store_hash.clone
78
+
74
79
  for i in options[:persist_attrs]
75
80
  if client.respond_to?(i)
76
81
  # only transfer the value if it is non-nil
77
82
  store_hash[i.to_s] = client.method(i).call unless client.method(i).call.nil?
78
83
  end
79
84
  end
85
+
86
+ wrapper.obj.method("#{options[:storage_attr]}=").call(store_hash)
87
+
80
88
  end
81
89
 
82
90
  def load_token_state wrapper, client
@@ -1,5 +1,5 @@
1
1
  module Signet
2
2
  module Rails
3
- VERSION = "0.0.7"
3
+ VERSION = "0.0.8"
4
4
  end
5
5
  end
data/tags ADDED
@@ -0,0 +1,37 @@
1
+ !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
2
+ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3
+ !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
4
+ !_TAG_PROGRAM_NAME Exuberant Ctags //
5
+ !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
6
+ !_TAG_PROGRAM_VERSION 5.9~svn20110310 //
7
+ ActiveRecord lib/signet/rails/wrappers/active_record.rb /^ class ActiveRecord$/;" c class:Signet.Rails.Wrappers
8
+ Builder lib/signet/rails/builder.rb /^ class Builder < ::Rack::Builder$/;" c class:Signet.Rails
9
+ Factory lib/signet/rails/factory.rb /^ class Factory$/;" c class:Signet.Rails
10
+ Handler lib/signet/rails/handler.rb /^ class Handler$/;" c class:Signet.Rails
11
+ Rails lib/signet/rails.rb /^ module Rails$/;" m class:Signet
12
+ Rails lib/signet/rails/builder.rb /^ module Rails$/;" m class:Signet
13
+ Rails lib/signet/rails/factory.rb /^ module Rails$/;" m class:Signet
14
+ Rails lib/signet/rails/handler.rb /^ module Rails$/;" m class:Signet
15
+ Rails lib/signet/rails/version.rb /^ module Rails$/;" m class:Signet
16
+ Rails lib/signet/rails/wrappers/active_record.rb /^ module Rails$/;" m class:Signet
17
+ Signet lib/signet/rails.rb /^module Signet$/;" m
18
+ Signet lib/signet/rails/builder.rb /^module Signet$/;" m
19
+ Signet lib/signet/rails/factory.rb /^module Signet$/;" m
20
+ Signet lib/signet/rails/handler.rb /^module Signet$/;" m
21
+ Signet lib/signet/rails/version.rb /^module Signet$/;" m
22
+ Signet lib/signet/rails/wrappers/active_record.rb /^module Signet$/;" m
23
+ Wrappers lib/signet/rails/wrappers/active_record.rb /^ module Wrappers$/;" m class:Signet.Rails
24
+ auth_options lib/signet/rails/handler.rb /^ def auth_options env$/;" f class:Signet.Rails.Handler
25
+ call lib/signet/rails/builder.rb /^ def call(env)$/;" f class:Signet.Rails.Builder
26
+ call lib/signet/rails/handler.rb /^ def call(env)$/;" f class:Signet.Rails.Handler
27
+ create_from_env lib/signet/rails/factory.rb /^ def self.create_from_env name, env, opt_hsh = {load_token: true}$/;" F class:Signet.Rails.Factory
28
+ handle lib/signet/rails/handler.rb /^ def handle(env)$/;" f class:Signet.Rails.Handler
29
+ initialize lib/signet/rails/builder.rb /^ def initialize(app, &block)$/;" f class:Signet.Rails.Builder
30
+ initialize lib/signet/rails/handler.rb /^ def initialize(app, opts = {}, auth_opts = {}, &block)$/;" f class:Signet.Rails.Handler
31
+ initialize lib/signet/rails/wrappers/active_record.rb /^ def initialize obj, client$/;" f class:Signet.Rails.Wrappers.ActiveRecord
32
+ load_token_state lib/signet/rails/handler.rb /^ def load_token_state wrapper, client$/;" f class:Signet.Rails.Handler
33
+ options lib/signet/rails/handler.rb /^ def options$/;" f class:Signet.Rails.Handler
34
+ persist lib/signet/rails/wrappers/active_record.rb /^ def persist$/;" f class:Signet.Rails.Wrappers.ActiveRecord
35
+ persist_token_state lib/signet/rails/handler.rb /^ def persist_token_state wrapper, client$/;" f class:Signet.Rails.Handler
36
+ provider lib/signet/rails/builder.rb /^ def provider(opts = {}, &block)$/;" f class:Signet.Rails.Builder
37
+ set_default_options lib/signet/rails/builder.rb /^ def self.set_default_options opts = {}$/;" F class:Signet.Rails.Builder
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: signet-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-12 00:00:00.000000000 Z
12
+ date: 2013-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -94,6 +94,7 @@ files:
94
94
  - lib/signet/rails/version.rb
95
95
  - lib/signet/rails/wrappers/active_record.rb
96
96
  - signet-rails.gemspec
97
+ - tags
97
98
  homepage: https://github.com/myitcv/signet-rails
98
99
  licenses:
99
100
  - MIT
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
116
  version: '0'
116
117
  requirements: []
117
118
  rubyforge_project:
118
- rubygems_version: 1.8.25
119
+ rubygems_version: 1.8.23
119
120
  signing_key:
120
121
  specification_version: 3
121
122
  summary: Incorporate Signet goodness into Rails