lib/representable/definition.rb in representable-0.11.0 vs lib/representable/definition.rb in representable-0.12.0
- old
+ new
@@ -1,17 +1,18 @@
module Representable
# Created at class compile time. Keeps configuration options for one property.
class Definition
- attr_reader :name, :sought_type, :from, :default
+ attr_reader :name, :sought_type, :from, :default, :representer_module
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?
+ @name = sym.to_s
+ @array = options[:collection]
+ @from = (options[:from] || name).to_s
+ @sought_type = options[:class] || options[:class] || :text # TODO: deprecate :class in 1.0.
+ @default = options[:default]
+ @default ||= [] if array?
+ @representer_module = options[:extend] # DISCUSS: move to Representable::DCI?
# FIXME: move me to xml.
if options[:from].to_s =~ /^@/
@sought_type = :attr
options[:from].sub!('@', '')