lib/sms_broker/setup.rb in sms_broker-1.0.0 vs lib/sms_broker/setup.rb in sms_broker-1.0.2
- old
+ new
@@ -1,26 +1,24 @@
module SmsBroker
-
class Setup
-
attr_reader :options,
:errors
def self.service_validation_schemas
{
- nexmo: Compel.hash.keys({
+ nexmo: Compel.hash.keys(
key: Compel.string.required,
secret: Compel.string.required,
sender_id: Compel.string,
phone_number: Compel.string.required
- }),
- twilio: Compel.hash.keys({
+ ),
+ twilio: Compel.hash.keys(
sender_id: Compel.string,
auth_token: Compel.string.required,
account_sid: Compel.string.required,
phone_number: Compel.string.required
- })
+ )
}
end
def initialize
@errors = {}
@@ -46,14 +44,14 @@
result.valid?
end
def compel_validation_schema(services_list = [])
- not_all_services_setup = Proc.new do |services_setups|
- services_list.all?{ |service|
+ not_all_services_setup = proc do |services_setups|
+ services_list.all? do |service|
services_setups.keys.include?(service.to_sym)
- }
+ end
end
services_setups_schema = \
Compel.hash.required
.keys(Setup.service_validation_schemas)
@@ -64,19 +62,17 @@
default_service: Compel.string.required.in(services_list),
services_setups: services_setups_schema
end
def method_missing(method, args, &block)
- service = "#{method}".split('_setup')[0].dup
+ service = method.to_s.split('_setup')[0].dup
if @options[:services].include?(service)
@options[:services_setups][service.to_sym] = args
@options[:services_setups]
else
super
end
end
-
end
-
end