lib/shapewear/dsl.rb in shapewear-0.0.2 vs lib/shapewear/dsl.rb in shapewear-0.0.3
- old
+ new
@@ -1,29 +1,43 @@
require 'builder'
-module Shapewear
- module DSL
- private
+module Shapewear::DSL
+ private
- def options
- @options ||= {}
- end
+ def options
+ @options ||= {}
+ end
- protected
+ def operations
+ options[:operations] ||= {}
+ end
- def wsdl_namespace(ns)
- options[:wsdl_namespace] = ns
- end
+ def namespaces
+ options[:namespaces] ||=
+ Hash.new { |_, k| raise "Namespace not defined: #{k}" } \
+ .merge! 'tns' => "http://services.example.com/#{self.name}",
+ 'xsd1' => "http://schema.example.com/#{self.name}",
+ 'wsdl' => 'http://schemas.xmlsoap.org/wsdl/',
+ 'soap' => 'http://schemas.xmlsoap.org/wsdl/soap/',
+ 'xsd' => 'http://www.w3.org/2000/10/XMLSchema',
+ 'env' => 'http://schemas.xmlsoap.org/soap/envelope/'
+ end
- def schema_namespace(ns)
- options[:schema_namespace] = ns
- end
+ protected
- def endpoint_url(url)
- options[:endpoint_url] = url
- end
+ def wsdl_namespace(ns)
+ namespaces['tns'] = ns
+ end
- def operation(name, ops = {})
- (options[:operations] ||= {})[name] = ops
- end
+ def schema_namespace(ns)
+ namespaces['xsd1'] = ns
+ end
+
+ def endpoint_url(url)
+ options[:endpoint_url] = url
+ end
+
+ def operation(name, ops = {})
+ h = (operations[name] ||= {}).merge! ops
+ h[:public_name] ||= name.to_s.camelize
end
end