From 1b07366c2fc12dcd38c1498e3239beb03103a09e Mon Sep 17 00:00:00 2001 From: Leon Breedt Date: Sat, 25 Jun 2005 18:57:33 +0000 Subject: add RDoc for base signature types git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1512 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionwebservice/lib/action_web_service/api.rb | 8 +++-- .../action_web_service/support/signature_types.rb | 35 +++++++++++++++------- 2 files changed, 30 insertions(+), 13 deletions(-) (limited to 'actionwebservice/lib/action_web_service') diff --git a/actionwebservice/lib/action_web_service/api.rb b/actionwebservice/lib/action_web_service/api.rb index 7db921b4a0..baf7856c6c 100644 --- a/actionwebservice/lib/action_web_service/api.rb +++ b/actionwebservice/lib/action_web_service/api.rb @@ -8,7 +8,11 @@ module ActionWebService # :nodoc: # # It is attached to web service implementation classes like # ActionWebService::Base and ActionController::Base derivatives by using - # ClassMethods#web_service_api. + # container.web_service_api, where container is an + # ActionController::Base or a ActionWebService::Base. + # + # See ActionWebService::Container::Direct::ClassMethods for an example + # of use. class Base # Whether to transform the public API method names into camel-cased names class_inheritable_option :inflect_names, true @@ -40,7 +44,7 @@ module ActionWebService # :nodoc: # A parameter specifier can be one of the following: # # * A symbol or string of representing one of the Action Web Service base types. - # See ActionWebService::Signature for a canonical list of the base types. + # See ActionWebService::SignatureTypes for a canonical list of the base types. # * The Class object of the parameter type # * A single-element Array containing one of the two preceding items. This # will cause Action Web Service to treat the parameter at that position diff --git a/actionwebservice/lib/action_web_service/support/signature_types.rb b/actionwebservice/lib/action_web_service/support/signature_types.rb index e0f0c2ecd8..2100eab131 100644 --- a/actionwebservice/lib/action_web_service/support/signature_types.rb +++ b/actionwebservice/lib/action_web_service/support/signature_types.rb @@ -1,6 +1,19 @@ module ActionWebService # :nodoc: - module SignatureTypes # :nodoc: - def canonical_signature(signature) + # Action Web Service supports the following base types in a signature: + # + # [:int] Represents an integer value, will be cast to an integer using Integer(value) + # [:string] Represents a string value, will be cast to an string using the to_s method on an object + # [:base64] Represents a Base 64 value, will contain the binary bytes of a Base 64 value sent by the caller + # [:bool] Represents a boolean value, whatever is passed will be cast to boolean (true, '1', 'true', 'y', 'yes' are taken to represent true; false, '0', 'false', 'n', 'no' and nil represent false) + # [:float] Represents a floating point value, will be cast to a float using Float(value) + # [:time] Represents a timestamp, will be cast to a Time object + # [:datetime] Represents a timestamp, will be cast to a DateTime object + # [:date] Represents a date, will be cast to a Date object + # + # For structured types, you'll need to pass in the Class objects of + # ActionWebService::Struct and ActiveRecord::Base derivatives. + module SignatureTypes + def canonical_signature(signature) # :nodoc: return nil if signature.nil? unless signature.is_a?(Array) raise(ActionWebServiceError, "Expected signature to be an Array") @@ -9,7 +22,7 @@ module ActionWebService # :nodoc: signature.map{ |spec| canonical_signature_entry(spec, i += 1) } end - def canonical_signature_entry(spec, i) + def canonical_signature_entry(spec, i) # :nodoc: orig_spec = spec name = "param#{i}" if spec.is_a?(Hash) @@ -28,14 +41,14 @@ module ActionWebService # :nodoc: end end - def canonical_type(type) + def canonical_type(type) # :nodoc: type_name = symbol_name(type) || class_to_type_name(type) type = type_name || type return canonical_type_name(type) if type.is_a?(Symbol) type end - def canonical_type_name(name) + def canonical_type_name(name) # :nodoc: name = name.to_sym case name when :int, :integer, :fixnum, :bignum @@ -59,17 +72,17 @@ module ActionWebService # :nodoc: end end - def canonical_type_class(type) + def canonical_type_class(type) # :nodoc: type = canonical_type(type) type.is_a?(Symbol) ? type_name_to_class(type) : type end - def symbol_name(name) + def symbol_name(name) # :nodoc: return name.to_sym if name.is_a?(Symbol) || name.is_a?(String) nil end - def class_to_type_name(klass) + def class_to_type_name(klass) # :nodoc: klass = klass.class unless klass.is_a?(Class) if derived_from?(Integer, klass) || derived_from?(Fixnum, klass) || derived_from?(Bignum, klass) :int @@ -92,7 +105,7 @@ module ActionWebService # :nodoc: end end - def type_name_to_class(name) + def type_name_to_class(name) # :nodoc: case canonical_type_name(name) when :int Integer @@ -115,7 +128,7 @@ module ActionWebService # :nodoc: end end - def derived_from?(ancestor, child) + def derived_from?(ancestor, child) # :nodoc: child.ancestors.include?(ancestor) end @@ -204,6 +217,6 @@ module ActionWebService # :nodoc: end end - class Base64 < String + class Base64 < String # :nodoc: end end -- cgit v1.2.3