class RestfulObjects::ParameterDescription
Attributes
description[RW]
format[RW]
friendly_name[RW]
id[R]
kind_type[R]
max_length[RW]
name[R]
number[R]
optional[RW]
pattern[RW]
type[R]
Public Class Methods
new(id, definition, number)
click to toggle source
# File lib/restful_objects/domain_model/types/parameter_description.rb, line 7 def initialize(id, definition, number) @id = id @name = id if definition.is_a?(Array)# [type, options] if [:string, :int, :decimal, :date, :blob].include?(definition.first) # scalar @kind_type = :scalar @type = definition.first elsif definition.first.is_a?(Class) # object type @kind_type = :object @type = definition.first.name elsif definition.first.is_a?(Strign) # object type @kind_type = :object @type = definition.first else raise "unssuported parameter definition type #{definition.class}" end options = definition.last elsif definition.is_a?(Symbol) # scalar type @kind_type = :scalar @type = definition raise "result type for scalar '#{@type}' unssuported" unless [:string, :int, :decimal, :date, :blob].include?(@type) elsif definition.is_a?(String)# object type @kind_type = :object @type = definition elsif definition.is_a?(Class)# object type @kind_type = :object @type = definition.to_s else raise "unssuported parameter definition type #{definition.class}" end options ||= {} @number = options[:number] || number @friendly_name = options[:friendly_name] || id @description = options[:description] || id @optional = options[:optional].nil? ? true : options[:optional] @max_length = options[:max_length] @pattern = options[:pattern] end
Public Instance Methods
metadata()
click to toggle source
# File lib/restful_objects/domain_model/types/parameter_description.rb, line 48 def metadata result = { 'friendlyName' => friendly_name, 'description' => description, 'optional' => optional, 'returnType' => type } result['maxLength'] = max_length if max_length result['pattern'] = pattern if pattern result['format'] = format if format result end