From dc7d3407001cc600f73bcab5361ce2193aeb5975 Mon Sep 17 00:00:00 2001 From: Sergey Kishenin Date: Tue, 12 Aug 2014 22:59:32 +0600 Subject: [PATCH] DRY configuration variables --- lib/rubykassa.rb | 2 +- lib/rubykassa/configuration.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/rubykassa.rb b/lib/rubykassa.rb index c789bba..276df9a 100644 --- a/lib/rubykassa.rb +++ b/lib/rubykassa.rb @@ -12,7 +12,7 @@ def configure &block Rubykassa::Client.configure &block end - %w(login first_password second_password mode http_method xml_http_method success_callback fail_callback result_callback).map do |name| + Rubykassa::Configuration::ATTRIBUTES.map do |name| define_method name do Rubykassa::Client.configuration.send(name) end diff --git a/lib/rubykassa/configuration.rb b/lib/rubykassa/configuration.rb index 0e7be96..290499a 100644 --- a/lib/rubykassa/configuration.rb +++ b/lib/rubykassa/configuration.rb @@ -1,10 +1,12 @@ # -*- encoding : utf-8 -*- module Rubykassa class Configuration - attr_accessor :login, :first_password, :second_password, :mode, :http_method, :xml_http_method - attr_accessor :success_callback - attr_accessor :fail_callback - attr_accessor :result_callback + ATTRIBUTES = [ + :login, :first_password, :second_password, :mode, :http_method, :xml_http_method, + :success_callback, :fail_callback, :result_callback + ] + + attr_accessor *ATTRIBUTES def initialize self.login = "your_login"