Class: BDsend

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

Overview

The BDsend class represent a strategy wich will use the context class to invoke the send function of the Connection Administrator. With this strategy the destination option value will be taken from a database specified in the configuration file, and the other option values will be taken from the context class

Instance Method Summary collapse

Instance Method Details

#send(context) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/smsruby/send.rb', line 167

def send(context)
  begin
    parse = YAML::parse(File.open(context.location))
    config = parse.transform
    db = SQLite3::Database.new(config['database']['db']+'.s3db')
    sql = "Select " + config['database']['field'] + " from " + config['database']['table']
    a = db.execute(sql) 
    context.dst=a
    context.adm.send(context.to_hash){|e| yield e if block_given?}
  rescue Exception=> e
   context.adm.log.error "BDsend Exception: #{e.message}"
   raise e.message
  end
end