lib/representable/definition.rb in representable-0.10.2 vs lib/representable/definition.rb in representable-0.10.3
- old
+ new
@@ -1,15 +1,17 @@
module Representable
# Created at class compile time. Keeps configuration options for one property.
class Definition
- attr_reader :name, :sought_type, :from
+ attr_reader :name, :sought_type, :from, :default
alias_method :getter, :name
def initialize(sym, options={})
@name = sym.to_s
@array = options[:collection]
@from = (options[:from] || name).to_s
@sought_type = options[:as] || :text
+ @default = options[:default]
+ @default ||= [] if array?
# FIXME: move me to xml.
if options[:from].to_s =~ /^@/
@sought_type = :attr
options[:from].sub!('@', '')