Class: Configsend

Inherits:
Object
  • Object
show all
Defined in:
lib/smsruby/send.rb

Overview

The Configsend class represent a strategy wich will use the received context class to invoke the send function of the Connection Administrator. With this strategy the option values will be obtain from a configuration file previosly created by user.

Instance Method Summary collapse

Instance Method Details

#send(context) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/smsruby/send.rb', line 142

def send(context)
  begin
    parse = YAML::parse(File.open(context.location))
    config = parse.transform
    dst = config['parameters']['dst'].split(',')
    context.dst=dst
    context.validity=(config['parameters']['validity']).to_s if !(config['parameters']['validity']=~/[0-9]*/)
    context.report=config['parameters']['report'] if !(config['parameters']['report']== 0 or config['parameters']['report'] == 1)
    context.smsc=config['parameters']['smsc'] if !(config['parameters']['smsc']=~/[0-9]*/)
    context.adm.send(context.to_hash){|e| yield e if block_given?}
  rescue Exception=> e
   context.adm.log.error "Configsend Exception: #{e.message}"
   raise e.message
  end
end