lib/sinatra/soap/wsdl.rb in sinatra-soap-0.1.4 vs lib/sinatra/soap/wsdl.rb in sinatra-soap-0.1.5

- old
+ new

@@ -1,34 +1,41 @@ -require 'singleton' - module Sinatra module Soap class Wsdl - include Singleton - attr_accessor :actions, :namespace + # class << self + # attr_accessor :actions + # end + @@actions = {} - def initialize - @actions = {} + def self.register(name, *args, &block) + @@actions = {} if @@actions.nil? + @@actions[name] = {} + args = args.pop + unless args.nil? + args.each do |key, value| + @@actions[name][key] = value + end + end + @@actions[name][:block] = block if block_given? end - def generate - # raise "Not implemented" + def self.generate end - def [](key) - actions[key] + attr_accessor :action, :block, :arguments + + def initialize(action) + data = all[action] + raise Soap::Error, "Undefined Soap Action" if data.nil? + @action = action + @block = data[:block] + @arguments = data.select {|k,v| k != :block} end - def register_action(name, *args, &block) - actions[name] = {} - args = args.pop - unless args.nil? - args.each do |key, value| - actions[name][key] = value - end - end - actions[name][:block] = block if block_given? + def all + @@actions end + end end end \ No newline at end of file