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

- old
+ new

@@ -5,10 +5,12 @@ alias_method :getter, :name def initialize(sym, options={}) @name = sym.to_s @options = options + + options[:default] ||= [] if array? # FIXME: move to CollectionBinding! end def clone self.class.new(name, options.clone) # DISCUSS: make generic Definition.cloned_attribute that passes list to constructor. end @@ -40,24 +42,26 @@ def default_for(value) return default if skipable_nil_value?(value) value end + def has_default? + options.has_key?(:default) + end + def representer_module options[:extend] end def attribute options[:attribute] end def skipable_nil_value?(value) - value.nil? and not options[:represent_nil] + value.nil? and not options[:render_nil] end - private def default - options[:default] ||= [] if array? # FIXME: move to CollectionBinding! options[:default] end end end