incline 0.2.12 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b9f04e383705923ed669444db1728cad58b4dc1
4
- data.tar.gz: 4208e2ae724bdd482f5a873222760cc92ff6283a
3
+ metadata.gz: 9190b8771a8a714428aced1fcfe7bfc14805898b
4
+ data.tar.gz: ef48cd977e79ac87f6dbf9100d5697b13ea5b636
5
5
  SHA512:
6
- metadata.gz: 49156fb0c524ed565747667157d38ec05cc6046bbe3a8ed0f76de316099c95050283f4e08d675d343cebb2a4b0956ea0680233588d7b7d7c818e260e129ed2a2
7
- data.tar.gz: 687c87d5802173415da2be71aff741f4224b3ee5a6f994436c6047ffb22687976ee1e060df2727d34cead3ef2c8b18b0c6b6c829c13c17a0dd9dd35d7c9172c7
6
+ metadata.gz: ad6466b33890e04ec20f51901b5fb2c67d8c638742de3621c218687a95e61b90e08d632d4e3965f6efdad2773ff08465537f7f04df0a9b6f95bebc821cdef3a4
7
+ data.tar.gz: 251f92afc831778e5e06be80165db66b9f2217919f1ab5d0502c4f6dda0ec7d8f66eab031781f52f7d8c1fb011db6d50a2ce5eb764ee49c638fd0406e090ad2a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- incline (0.2.12)
4
+ incline (0.2.13)
5
5
  ansi (~> 1.5.0)
6
6
  bcrypt
7
7
  bootstrap-sass
@@ -26,6 +26,7 @@ require 'incline/extensions/active_record_base'
26
26
  require 'incline/extensions/connection_adapter'
27
27
  require 'incline/extensions/main_app'
28
28
  require 'incline/extensions/action_controller_base'
29
+ require 'incline/extensions/current_request'
29
30
  require 'incline/extensions/action_mailer_base'
30
31
  require 'incline/extensions/action_view_base'
31
32
  require 'incline/extensions/session'
@@ -40,6 +41,7 @@ require 'incline/extensions/float_value'
40
41
  require 'incline/extensions/decimal_value'
41
42
  require 'incline/extensions/date_time_value'
42
43
  require 'incline/extensions/date_value'
44
+ require 'incline/extensions/param_propagation'
43
45
 
44
46
  # Validators
45
47
  require 'incline/validators/email_validator'
@@ -0,0 +1,25 @@
1
+ module Incline::Extensions
2
+ module CurrentRequest
3
+ def self.included(base)
4
+ base.class_eval do
5
+ private
6
+
7
+ def store_current_request
8
+ ::Thread.current.thread_variable_set :incline_current_request, request
9
+ end
10
+
11
+ before_action :store_current_request
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ module Incline
18
+ def self.current_request
19
+ th = ::Thread.current
20
+ th.thread_variable?(:incline_current_request) ? th.thread_variable_get(:incline_current_request) : nil
21
+ end
22
+ end
23
+
24
+ ActionController::Base.include ::Incline::Extensions::CurrentRequest
25
+
@@ -0,0 +1,38 @@
1
+ require 'action_dispatch/http/url'
2
+
3
+ module ActionDispatch::Http::URL
4
+
5
+ ##
6
+ # Enables automatic parameter propagation.
7
+ #
8
+ # This will only propagate within the current thread. Child threads will not propagate.
9
+ # This will not affect other requests in the current session.
10
+ #
11
+ # ActionDispatch::Http::URL.propagated_params << :some_param
12
+ def self.propagated_params
13
+ @propagated_params ||= []
14
+ end
15
+
16
+ def self.path_for(options)
17
+
18
+ if (request = Incline::current_request)
19
+ propagated_params.each do |k|
20
+ if request.params.key? k
21
+ options[:params] ||= {}
22
+ options[:params][k] = request.params[k]
23
+ end
24
+ end
25
+ end
26
+
27
+ path = options[:script_name].to_s.chomp("/")
28
+ path << options[:path] if options.key?(:path)
29
+
30
+ add_trailing_slash(path) if options[:trailing_slash]
31
+ add_params(path, options[:params]) if options.key?(:params)
32
+ add_anchor(path, options[:anchor]) if options.key?(:anchor)
33
+
34
+ path
35
+ end
36
+
37
+ end
38
+
@@ -1,3 +1,3 @@
1
1
  module Incline
2
- VERSION = "0.2.12"
2
+ VERSION = "0.2.13"
3
3
  end
data/test/incline_test.rb CHANGED
@@ -34,6 +34,7 @@ class InclineTest < ActiveSupport::TestCase
34
34
  assert Incline::Extensions.const_defined? :ConnectionAdapter
35
35
  assert Incline::Extensions.const_defined? :MainApp
36
36
  assert Incline::Extensions.const_defined? :ActionControllerBase
37
+ assert Incline::Extensions.const_defined? :CurrentRequest
37
38
  assert Incline::Extensions.const_defined? :ActionMailerBase
38
39
  assert Incline::Extensions.const_defined? :ActionViewBase
39
40
  assert Incline::Extensions.const_defined? :Session
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: incline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beau Barker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-22 00:00:00.000000000 Z
11
+ date: 2017-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -427,6 +427,7 @@ files:
427
427
  - lib/incline/extensions/application.rb
428
428
  - lib/incline/extensions/application_configuration.rb
429
429
  - lib/incline/extensions/connection_adapter.rb
430
+ - lib/incline/extensions/current_request.rb
430
431
  - lib/incline/extensions/date_time_value.rb
431
432
  - lib/incline/extensions/date_value.rb
432
433
  - lib/incline/extensions/decimal_value.rb
@@ -439,6 +440,7 @@ files:
439
440
  - lib/incline/extensions/main_app.rb
440
441
  - lib/incline/extensions/numeric.rb
441
442
  - lib/incline/extensions/object.rb
443
+ - lib/incline/extensions/param_propagation.rb
442
444
  - lib/incline/extensions/resource_route_generator.rb
443
445
  - lib/incline/extensions/session.rb
444
446
  - lib/incline/extensions/string.rb