Started on the ExtendedDocument class with features moved to mixins.

Properties got added, they define getters, setters and aliases.
They will also be the base of the new validation system.
This commit is contained in:
Matt Aimonetti 2009-01-29 18:45:01 -08:00
parent 90f460641e
commit d6665e55ca
12 changed files with 539 additions and 8 deletions

View file

@ -0,0 +1,26 @@
module CouchRest
# Basic attribute support adding getter/setter + validation
class Property
attr_reader :name, :type, :validation_format, :required, :read_only, :alias
# attribute to define
def initialize(name, type = String, options = {})
@name = name.to_s
@type = type
parse_options(options)
self
end
private
def parse_options(options)
return if options.empty?
@required = true if (options[:required] && (options[:required] == true))
@validation_format = options[:format] if options[:format]
@read_only = options[:read_only] if options[:read_only]
@alias = options[:alias] if options
end
end
end