module AttributedObject::Base::ClassExtension
Public Instance Methods
ArrayOf(type_info)
click to toggle source
# File lib/attributed_object/types/array_of.rb, line 22 def ArrayOf(type_info) AttributedObject::Types::ArrayOf.new(type_info) end
HashOf(key_type_info, value_type_info)
click to toggle source
# File lib/attributed_object/types/hash_of.rb, line 25 def HashOf(key_type_info, value_type_info) AttributedObject::Types::HashOf.new(key_type_info, value_type_info) end
attribute(attr_name, type_info = Unset, default: Unset, disallow: Unset, whitelist: Unset)
click to toggle source
# File lib/attributed_object/base.rb, line 29 def attribute(attr_name, type_info = Unset, default: Unset, disallow: Unset, whitelist: Unset) if default == Unset default_to = attributed_object_options.fetch(:default_to) if default_to != Unset default = default_to.is_a?(TypeDefaults) ? default_to.fetch(type_info) : default_to end end if disallow == Unset disallow = attributed_object_options.fetch(:disallow) end if whitelist == Unset whitelist = attributed_object_options.fetch(:whitelist) end _attributed_object_check_type_supported!(type_info) attribute_defs[attr_name] = { type_info: type_info, default: default, disallow: disallow, whitelist: whitelist } attr_writer attr_name attr_reader attr_name end
attribute_defs()
click to toggle source
# File lib/attributed_object/base.rb, line 22 def attribute_defs return @attribute_defs if @attribute_defs parent_defs = {} parent_defs = self.superclass.attribute_defs if self.superclass.respond_to?(:attribute_defs) @attribute_defs = parent_defs.clone end
attributed_object(options={})
click to toggle source
# File lib/attributed_object/base.rb, line 4 def attributed_object(options={}) @attributed_object_options = attributed_object_options.merge(options) end
attributed_object_options()
click to toggle source
# File lib/attributed_object/base.rb, line 8 def attributed_object_options return @attributed_object_options if !@attributed_object_options.nil? parent_ops = self.superclass.respond_to?(:attributed_object_options) ? self.superclass.attributed_object_options : {} @attributed_object_options = { default_to: Unset, ignore_extra_keys: false, coerce_blanks_to_nil: false, disallow: Unset, whitelist: Unset }.merge(parent_ops) end