lib/representable/definition.rb in representable-1.1.7 vs lib/representable/definition.rb in representable-1.2.0

- old
+ new

@@ -35,19 +35,29 @@ def from (options[:from] || name).to_s end - def default - options[:default] ||= [] if array? # FIXME: move to CollectionBinding! - options[:default] + def default_for(value) + return default if skipable_nil_value?(value) + value end def representer_module options[:extend] end def attribute options[:attribute] + end + + def skipable_nil_value?(value) + value.nil? and not options[:represent_nil] + end + + private + def default + options[:default] ||= [] if array? # FIXME: move to CollectionBinding! + options[:default] end end end