rubykassa 0.3.2 → 0.4.0

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: dd92e78dd2880fad505c7e4bcf561a011c0ebabd
4
- data.tar.gz: 7075c5b4b5a8b7d5852f2de6e985bba652e23455
3
+ metadata.gz: 3bb9879d9d2b86beba88015e506782c4bd57fd4d
4
+ data.tar.gz: b47aa33a7cad9f81ec111b031b911ab2e9ac41d9
5
5
  SHA512:
6
- metadata.gz: a1800cc9729f3a985d9aabf204b3199c251f5b2bdfc6bbe7425256a5e797fb54c148b16f9f3d71ccbcf81bc6b5cf1606588501690b7863b3f21e7a609994f5c3
7
- data.tar.gz: 71a029822a6eaf978bd1cd0b950ca9c1ae3a231f556d177188795bdb823f61b7b8b837873ef3e7169ba065b56f9779906307f8e88e87e8ec5f29b16c243666ed
6
+ metadata.gz: 3370eb1c5bf9c0923ac17d4795f381d1d2ad120128a5858888ff11c9fc3e8d292addeb77e7cc2362e376ae0141f046dc3aa77e5f7d49d4fb6233518cd5bdf3a5
7
+ data.tar.gz: 216ff6f6ab2db1479ea5e2108ce7c4a0090a7a4e35d324afc53f770c679733346b736686b0cf143f933127114b71c09f88fedff3881a1653d28ba10aa4fa32e7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## Edge (not released)
2
2
 
3
+ ## 0.4.0
4
+
5
+ * Simplify callbacks logic: no more necessity to pass `controller` variable to lambda. Thanks @BrainNya for active promotion.
6
+
3
7
  ## 0.3.2
4
8
 
5
9
  * Add confugurable result callback [#14][]
data/README.md CHANGED
@@ -48,12 +48,12 @@ To define custom success/fail callbacks you can also use the initializer:
48
48
 
49
49
  Rubykassa.configure do |config|
50
50
  ...
51
- config.success_callback = -> (controller, notification) { controller.render text: 'success' }
52
- config.fail_callback = -> (controller, notification) { controller.redirect_to controller.root_path }
53
- config.result_callback = -> (controller, notification) { controller.render text: notification.success }
51
+ config.success_callback = -> (notification) { render text: 'success' }
52
+ config.fail_callback = -> (notification) { redirect_to root_path }
53
+ config.result_callback = -> (notification) { render text: notification.success }
54
54
  end
55
55
 
56
- Lambdas are called in RobokassaController so you can respond with [any kind that is supported by Rails](http://guides.rubyonrails.org/layouts_and_rendering.html#creating-responses) calling it on the `controller` variable.
56
+ Lambdas are called in RobokassaController so you can respond with [any kind that is supported by Rails](http://guides.rubyonrails.org/layouts_and_rendering.html#creating-responses).
57
57
 
58
58
  NOTE: `result_callback` should always return `"OK#{ invoice_id }"` string. So, implement your custom logic above `render text: notification.success` line.
59
59
 
@@ -4,22 +4,22 @@ class RobokassaController < ApplicationController
4
4
 
5
5
  def paid
6
6
  if @notification.valid_result_signature?
7
- Rubykassa.result_callback.call(self, @notification)
7
+ instance_exec @notification, &Rubykassa.result_callback
8
8
  else
9
- Rubykassa.fail_callback.call(self, @notification)
9
+ instance_exec @notification, &Rubykassa.fail_callback
10
10
  end
11
11
  end
12
12
 
13
13
  def success
14
14
  if @notification.valid_success_signature?
15
- Rubykassa.success_callback.call(self, @notification)
15
+ instance_exec @notification, &Rubykassa.success_callback
16
16
  else
17
- Rubykassa.fail_callback.call(self, @notification)
17
+ instance_exec @notification, &Rubykassa.fail_callback
18
18
  end
19
19
  end
20
20
 
21
21
  def fail
22
- Rubykassa.fail_callback.call(self, @notification)
22
+ instance_exec @notification, &Rubykassa.fail_callback
23
23
  end
24
24
 
25
25
  private
@@ -10,12 +10,12 @@ Rubykassa.configure do |config|
10
10
 
11
11
  # Result callback is called in RobokassaController#paid action if valid signature
12
12
  # was generated. It should always return "OK#{ invoice_id }" string, so implement
13
- # your custom logic above `controller.render text: notification.success` line
13
+ # your custom logic above `render text: notification.success` line
14
14
 
15
- config.result_callback = -> (controller, notification) { controller.render text: notification.success }
15
+ config.result_callback = -> (notification) { render text: notification.success }
16
16
 
17
17
  # Define success or failure callbacks here like:
18
18
 
19
- # config.success_callback = -> (controller, notification) { controller.render text: 'success' }
20
- # config.fail_callback = -> (controller, notification) { controller.redirect_to controller.root_path }
19
+ # config.success_callback = -> (notification) { render text: 'success' }
20
+ # config.fail_callback = -> (notification) { redirect_to root_path }
21
21
  end
data/lib/rubykassa.rb CHANGED
@@ -12,7 +12,7 @@ module Rubykassa
12
12
  Rubykassa::Client.configure &block
13
13
  end
14
14
 
15
- %w(login first_password second_password mode http_method xml_http_method success_callback fail_callback result_callback).map do |name|
15
+ Rubykassa::Configuration::ATTRIBUTES.map do |name|
16
16
  define_method name do
17
17
  Rubykassa::Client.configuration.send(name)
18
18
  end
@@ -1,27 +1,23 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Rubykassa
3
3
  class Configuration
4
- attr_accessor :login, :first_password, :second_password, :mode, :http_method, :xml_http_method
5
- attr_accessor :success_callback
6
- attr_accessor :fail_callback
7
- attr_accessor :result_callback
4
+ ATTRIBUTES = [
5
+ :login, :first_password, :second_password, :mode, :http_method, :xml_http_method,
6
+ :success_callback, :fail_callback, :result_callback
7
+ ]
8
+
9
+ attr_accessor *ATTRIBUTES
8
10
 
9
11
  def initialize
10
12
  self.login = "your_login"
11
- self.first_password = "first_password"
12
- self.second_password = "second_password"
13
- self.mode = :test
14
- self.http_method = :get
15
- self.xml_http_method = :get
16
- self.success_callback = Proc.new do |controller, notification|
17
- render text: 'success'
18
- end
19
- self.fail_callback = Proc.new do |controller, notification|
20
- render text: 'fail'
21
- end
22
- self.result_callback = Proc.new do |controller, notification|
23
- render text: notification.success
24
- end
13
+ self.first_password = "first_password"
14
+ self.second_password = "second_password"
15
+ self.mode = :test
16
+ self.http_method = :get
17
+ self.xml_http_method = :get
18
+ self.success_callback = -> (notification) { render text: 'success' }
19
+ self.fail_callback = -> (notification) { render text: 'fail' }
20
+ self.result_callback = -> (notification) { render text: notification.success }
25
21
  end
26
22
  end
27
23
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Rubykassa
3
- VERSION = "0.3.2"
3
+ VERSION = "0.4.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubykassa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Kishenin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-11 00:00:00.000000000 Z
11
+ date: 2014-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails