Method: RestfulObjects::PropertyDescription#initialize
- Defined in:
- lib/restful_objects/domain_model/types/property_description.rb
#initialize(id, domain_type, return_type, options) ⇒ PropertyDescription
Returns a new instance of PropertyDescription.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/restful_objects/domain_model/types/property_description.rb', line 7 def initialize(id, domain_type, return_type, ) if return_type.is_a?(Hash) raise "hash with :object key expected for property reference" unless return_type.has_key?(:object) else raise "property type #{return_type} usupported" unless [:string, :int, :bool, :decimal, :date, :blob].include?(return_type) end @id = id @domain_type = domain_type if return_type.is_a?(Hash) @return_type = return_type[:object] @is_reference = true else @return_type = return_type @is_reference = false end @friendly_name = [:friendly_name] || id @description = [:description] || id @optional = [:optional].nil? ? true : [:optional] @read_only = [:read_only].nil? ? false : [:read_only] @member_order = [:member_order] || 1 @max_length = [:max_length] @disabled_reason = [:disabled_reason] || 'read-only property' if read_only @pattern = [:pattern] end |