lib/olaf/service_helpers.rb
#
# This checks values against Olaf::Service param types.
# A param type is normally specified as a hash of property names
# to types (param types, Ruby types or models).
#
# Normally, type would be specified as something like:
#
# { :name => String, :num => [Fixnum],
#   :id => Olaf::Required[Fixnum] }
#
This checks values against Olaf::Service param types.
A param type is normally specified as a hash of property names
to types (param types, Ruby types or models).

Normally, type would be specified as something like.


This checks values against Olaf :: Service param types . A param type is normally specified as a hash of property names to types ( param types Ruby types or models ) . Normally type would be specified as something like .
def check_domain_object_type_against_value(param_type, value, options)
      if value.is_a?(Hash)
        return param_type.check_hash_against_domain_object(value, options)
      elsif value.is_a?(String)
        begin
          hash = JSON.parse(value)
        rescue => e
          param_type_error "Value #{value.inspect} cannot be converted to a hash for checking against #{param_type}."
        end
        return param_type.check_hash_against_domain_object(hash, options)
      else
        if value.is_a?(param_type)
          return value
        else
          param_type_error "Value #{value} is a #{value.class}, which cannot be converted to #{param_type}."
        end
      end
    end
def check_domain_object_type_against_value ( param_type , value , options ) if value . is_a? ( Hash ) return param_type . check_hash_against_domain_object ( value , options ) elsif value . is_a? ( String ) begin hash = JSON . parse ( value ) rescue => e param_type_error "Value #{value.inspect} cannot be converted to a hash for checking against #{param_type}." end return param_type . check_hash_against_domain_object ( hash , options ) else if value . is_a? ( param_type ) return value else param_type_error "Value #{value} is a #{value.class}, which cannot be converted to #{param_type}." end end end
This checks values against Olaf::Service param types.
This checks values against Olaf :: Service param types .
param_type
value
options